-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from bettyblocks/feat/introduce-size-option-he…
…lper-PAGE-1873 feat: new helper for size option
- Loading branch information
Showing
3 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { | ||
PrefabComponentOption, | ||
ValueDefault, | ||
ValueRef, | ||
} from '../../types/options'; | ||
|
||
type OptionProducer = (key: string) => PrefabComponentOption; | ||
|
||
// typescript issue #36981 | ||
// Omit is currently desctructive to union/extended types see | ||
// So we have to Omit each variant as a work around | ||
type RedundantKeys = 'type' | 'key' | 'label'; | ||
type Attributes = | ||
| Omit<ValueDefault, RedundantKeys> | ||
| Omit<ValueRef, RedundantKeys>; | ||
|
||
const defaultAttributes = { | ||
value: [], | ||
}; | ||
|
||
export const size = | ||
(label: string, attrs: Attributes): OptionProducer => | ||
(key) => ({ | ||
...defaultAttributes, | ||
...attrs, | ||
key, | ||
type: 'SIZE', | ||
label, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters