Skip to content

Commit

Permalink
Merge pull request #20 from bettyblocks/feat/introduce-size-option-he…
Browse files Browse the repository at this point in the history
…lper-PAGE-1873

feat: new helper for size option
  • Loading branch information
M authored May 16, 2022
2 parents ef8cd50 + 8b5837f commit 5c5c1be
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/prefabs/factories/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export { font } from './font';
export { option } from './option';
export { toggle } from './toggle';
export { sizes } from './sizes';
export { size } from './size';
export { variable } from './variable';
export { buttongroup } from './buttongroup';
export { dropdown } from './dropdown';
Expand Down
29 changes: 29 additions & 0 deletions src/prefabs/factories/options/size.ts
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,
});
2 changes: 1 addition & 1 deletion src/prefabs/types/prefabs/theme-color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export enum ThemeColor {
ACCENT_1 = 'Accent1',
ACCENT_2 = 'Accent2',
ACCENT_3 = 'Accent3',
TRANSPARENT = 'transparent',
TRANSPARENT = 'Transparent',
}

0 comments on commit 5c5c1be

Please sign in to comment.