@openfin/ui-library 0.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +260 -0
  2. package/dist/components/elements/Button/button.d.ts +37 -0
  3. package/dist/components/elements/Button/button.js +91 -0
  4. package/dist/components/elements/Button/button.variants.d.ts +64 -0
  5. package/dist/components/elements/Button/button.variants.js +105 -0
  6. package/dist/components/elements/Button/index.d.ts +2 -0
  7. package/dist/components/elements/Button/index.js +14 -0
  8. package/dist/components/elements/Icon/icon.d.ts +15 -0
  9. package/dist/components/elements/Icon/icon.js +56 -0
  10. package/dist/components/elements/Icon/icon.variants.d.ts +28 -0
  11. package/dist/components/elements/Icon/icon.variants.js +60 -0
  12. package/dist/components/elements/Icon/index.d.ts +1 -0
  13. package/dist/components/elements/Icon/index.js +13 -0
  14. package/dist/components/elements/Input/index.d.ts +1 -0
  15. package/dist/components/elements/Input/index.js +13 -0
  16. package/dist/components/elements/Input/input.d.ts +8 -0
  17. package/dist/components/elements/Input/input.js +26 -0
  18. package/dist/components/elements/Toggle/index.d.ts +1 -0
  19. package/dist/components/elements/Toggle/index.js +13 -0
  20. package/dist/components/elements/Toggle/toggle.d.ts +10 -0
  21. package/dist/components/elements/Toggle/toggle.js +111 -0
  22. package/dist/components/elements/Toggle/toggle.variants.d.ts +26 -0
  23. package/dist/components/elements/Toggle/toggle.variants.js +62 -0
  24. package/dist/components/layout/Box/box.d.ts +27 -0
  25. package/dist/components/layout/Box/box.js +42 -0
  26. package/dist/components/layout/Box/index.d.ts +1 -0
  27. package/dist/components/layout/Box/index.js +13 -0
  28. package/dist/components/layout/Box/types.d.ts +7 -0
  29. package/dist/components/layout/Box/types.js +2 -0
  30. package/dist/components/system/GlobalStyles/globalStyles.d.ts +1 -0
  31. package/dist/components/system/GlobalStyles/globalStyles.js +54 -0
  32. package/dist/components/system/GlobalStyles/index.d.ts +1 -0
  33. package/dist/components/system/GlobalStyles/index.js +13 -0
  34. package/dist/components/system/ThemeProvider/index.d.ts +6 -0
  35. package/dist/components/system/ThemeProvider/index.js +18 -0
  36. package/dist/components/system/ThemeProvider/lib/config.d.ts +7 -0
  37. package/dist/components/system/ThemeProvider/lib/config.js +9 -0
  38. package/dist/components/system/ThemeProvider/lib/constants.d.ts +526 -0
  39. package/dist/components/system/ThemeProvider/lib/constants.js +269 -0
  40. package/dist/components/system/ThemeProvider/lib/font-face-base64.d.ts +2 -0
  41. package/dist/components/system/ThemeProvider/lib/font-face-base64.js +71 -0
  42. package/dist/components/system/ThemeProvider/lib/font-face-cdn.d.ts +2 -0
  43. package/dist/components/system/ThemeProvider/lib/font-face-cdn.js +48 -0
  44. package/dist/components/system/ThemeProvider/lib/helpers.d.ts +19 -0
  45. package/dist/components/system/ThemeProvider/lib/helpers.js +31 -0
  46. package/dist/components/system/ThemeProvider/lib/interface.d.ts +25 -0
  47. package/dist/components/system/ThemeProvider/lib/interface.js +2 -0
  48. package/dist/components/system/ThemeProvider/lib/palette.d.ts +28 -0
  49. package/dist/components/system/ThemeProvider/lib/palette.js +31 -0
  50. package/dist/components/system/ThemeProvider/lib/types.d.ts +49 -0
  51. package/dist/components/system/ThemeProvider/lib/types.js +2 -0
  52. package/dist/components/system/ThemeProvider/themeProvider.d.ts +20 -0
  53. package/dist/components/system/ThemeProvider/themeProvider.js +20 -0
  54. package/dist/components/system/ThemeProvider/themes/index.d.ts +1 -0
  55. package/dist/components/system/ThemeProvider/themes/index.js +13 -0
  56. package/dist/components/system/ThemeProvider/themes/openfin.d.ts +9 -0
  57. package/dist/components/system/ThemeProvider/themes/openfin.js +28 -0
  58. package/dist/components/typography/Heading/heading.d.ts +1608 -0
  59. package/dist/components/typography/Heading/heading.js +64 -0
  60. package/dist/components/typography/Heading/index.d.ts +1 -0
  61. package/dist/components/typography/Heading/index.js +13 -0
  62. package/dist/components/typography/Text/index.d.ts +1 -0
  63. package/dist/components/typography/Text/index.js +13 -0
  64. package/dist/components/typography/Text/text.d.ts +15 -0
  65. package/dist/components/typography/Text/text.js +20 -0
  66. package/dist/hooks/useColorScheme.d.ts +12 -0
  67. package/dist/hooks/useColorScheme.js +28 -0
  68. package/dist/hooks/useMediaQuery.d.ts +12 -0
  69. package/dist/hooks/useMediaQuery.js +39 -0
  70. package/dist/hooks/useTheme.d.ts +9 -0
  71. package/dist/hooks/useTheme.js +32 -0
  72. package/dist/index.d.ts +12 -0
  73. package/dist/index.js +37 -0
  74. package/dist/storybookHelpers.d.ts +84 -0
  75. package/dist/storybookHelpers.js +55 -0
  76. package/package.json +133 -0
package/README.md ADDED
@@ -0,0 +1,260 @@
1
+ # OpenFin UI Library
2
+
3
+ **[openfin-ui.netlify.com](https://openfin-ui.netlify.com)** `pw: pizza`
4
+
5
+ [![Netlify Status](https://api.netlify.com/api/v1/badges/8fc15443-c69c-473b-b5cf-c5dbc516b0bf/deploy-status)](https://app.netlify.com/sites/openfin-ui/deploys)
6
+
7
+ ## Installation
8
+
9
+ This packaged library is privately managed with [GitHub Packages](https://github.com/features/packages), and can be installed via npm/yarn like any other npm package. All release versions can be viewed under the Packages section of this repo.
10
+
11
+ ### 1. Setup access to Github private package
12
+
13
+ There are a few ways to do this, here's one way 👇
14
+
15
+ ```sh
16
+ # .npmrc in downstream application repository consuming UI Library
17
+ @openfin:registry=https://npm.pkg.github.com/
18
+ //npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
19
+ ```
20
+
21
+ ```sh
22
+ # .zshrc or .bash_profile
23
+ export GITHUB_TOKEN=<Your Github Personalized Access Token with READ access to this Repository>
24
+ ```
25
+
26
+ ### 2. Install the package
27
+
28
+ ```bash
29
+ # Install the latest version
30
+ $ yarn add @openfin/ui-library
31
+ ```
32
+
33
+ ```bash
34
+ # Install a specific version
35
+ $ yarn add @openfin/ui-library@v1.0.1
36
+ ```
37
+
38
+ ## Working in tandem on UI Library and Application
39
+
40
+ Sometimes you may need to work on the `ui-library` alongside your own application. We use [yalc](https://www.npmjs.com/package/yalc) for this. It solves a few problems that `yarn link` creates and it's pretty intuitive
41
+
42
+ ### 1. Install and setup yalc
43
+
44
+ ```bash
45
+ # Make sure yalc is installed globally
46
+ $ npm i yalc -g
47
+
48
+ # Set up yalc in ui-library
49
+ $ cd ui-library/
50
+ $ yalc publish
51
+
52
+ # Add local ui-library package to your app
53
+ $ cd ../myCoolApp/
54
+ $ yalc add @openfin/ui-library
55
+ ```
56
+
57
+ This links your local copy of UI Library to your app using symlinks and `package.json`.
58
+
59
+ ### 2. Working with yalc
60
+
61
+ Once you're setup, subsequent changes in UI Library can be propagated across easily.
62
+
63
+ After making changes in `ui-library`, run `yarn build && yalc push`. This will apply a version bump to the local yalc package respository. It will also update the package in your app directory, but you will most likely need to restart any development servers to see the changes.
64
+
65
+ ```sh
66
+ # push updates from ui-library side to your app
67
+ $ yarn build && yalc push
68
+ ```
69
+
70
+ #### Known Issues
71
+
72
+ - Storybook does not pick up changes after a `yalc push` and must be restarted
73
+
74
+ ## Using UI Library
75
+
76
+ ### Theme Provider
77
+
78
+ The `ThemeProvider` is a component that provides theme information to the `ui-library` components nested deeply within your application. Make sure to include this above your application so your components will be styled properly.
79
+
80
+ ```javascript
81
+ import { ThemeProvider } from '@openfin/ui-library';
82
+ import MyApp from 'some/cool/place';
83
+
84
+ const MyCoolAppContainer = () => (
85
+ <ThemeProvider>
86
+ <MyApp />
87
+ </ThemeProvider>
88
+ );
89
+ ```
90
+
91
+ ## [Storybook](https://storybook.js.org)
92
+
93
+ Great for exploring and experimenting with UI Library components. It's also a used for [testing our components](https://storybook.js.org/docs/react/workflows/unit-testing).
94
+
95
+ ### Storybook For Developers
96
+
97
+ ```bash
98
+ $ yarn storybook
99
+ ```
100
+
101
+ ### Storybook For Designers
102
+
103
+ Great for a quick look at the latest build, [check it out](https://openfin-ui.netlify.com)
104
+
105
+ ## Codesandbox.io
106
+
107
+ Coming Soon, great tool for developer experimentation without the overhead of forking the library or integrating it into an existing application.
108
+
109
+ `@TODO` Setup a Codesandbox Playground [PE-27](https://appoji.jira.com/browse/PE-10)
110
+
111
+ ## How to test
112
+
113
+ ```sh
114
+ yarn test
115
+ ```
116
+
117
+ ## How to Contribute
118
+
119
+ ### 1. Enable the pre-push hook
120
+
121
+ ```sh
122
+ touch .git/hooks/pre-push &&
123
+ printf "yarn git:pre-push" >> .git/hooks/pre-push &&
124
+ chmod +x .git/hooks/pre-push
125
+ ```
126
+
127
+ ### 2. Open a pull request 😎
128
+
129
+ Pull requests are a great way to express an idea or need, if it's easier to "show" instead of "tell", go for it, propose a change!
130
+
131
+ Also keep in mind, UI Library is a home of centralized common elements, **used by several products**. It's reasonable to expect PRs may spark conversations about the **essence of the change** and it's benefits and impact across the application ecosystem.
132
+
133
+ Meaning: While there are no hard rules about what belongs in _our_ library, if a change is too opinionated or too specialized, it may make sense to leave it out. **A library that does less, is a lot easier to know and work with**.
134
+
135
+ ## Compiling the Library
136
+
137
+ ### `tsonfig.json`
138
+
139
+ The base Typescript config.
140
+
141
+ ### `tsonfig.bundle.json`
142
+
143
+ Extending base config used by `tsc` when bundling the library for a new release.
144
+
145
+ ### `tsonfig.storybook.json`
146
+
147
+ Extending base config used by `Storybook` to quiet some extraneous warnings.
148
+
149
+ ## Versioning & Releasing
150
+
151
+ ### 1. Create a release branch
152
+
153
+ Note the new release version, and create a branch from `main` solely for versioning:
154
+
155
+ ```sh
156
+ # Fetch and merge latest main branch
157
+ $ git checkout main && git pull
158
+
159
+ # Create new release branch
160
+ $ git checkout -b release/<new-version-number>
161
+
162
+ # Commit new version
163
+ $ npm version <major|minor|patch>
164
+
165
+ # Push release branch remotely
166
+ $ git push -u origin release/<new-version-number>
167
+ ```
168
+
169
+ ### 2. Create a pull request
170
+
171
+ You should now be able to open a pull request with `release/<new-version-number>` against `main`. Get that approved and merged.
172
+
173
+ ### 3. Create a new release on Github
174
+
175
+ Once your release branch is merged into main, you should now create a release through github:
176
+
177
+ - Click [Create a New Release](https://github.com/openfin/ui-library/releases/new)
178
+ - Enter the version name as the tag and the release title
179
+ - Enter a description that includes all feature ticket numbers that were included since the previous release. Don't worry, you can always go back and edit it later.
180
+
181
+ This triggers a Github Action to automatically build the latest version of the `ui-library` and package it for remote installation. Check the status of this task within this repo's actions tab.
182
+
183
+ ## Components
184
+
185
+ ### Elements
186
+
187
+ - [Button](./src/components/elements/Button)
188
+ - [Icon](./src/components/elements/Icon)
189
+ - [Input](./src/components/elements/Input)
190
+ - [Toggle](./src/components/elements/Toggle)
191
+
192
+ ### Layout
193
+
194
+ - [Box](./src/components/layout/Box)
195
+
196
+ ### System
197
+
198
+ - [GlobalStyles](./src/components/system/GlobalStyles)
199
+ - [ThemeProvider](./src/components/system/ThemeProvider)
200
+ - [Themes](./src/components/system/ThemeProvider/themes) (included OpenFin Themes)
201
+
202
+ ### [Typography](./src/components/typography)
203
+
204
+ - Text
205
+ - Heading
206
+
207
+ ## [Hooks](./src/hooks)
208
+
209
+ - useMediaQuery
210
+ - useLayoutMediaQuery
211
+ - useColorScheme
212
+ - useTheme
213
+
214
+ ## Variants
215
+
216
+ ### What are variants?
217
+
218
+ Variants as a concept is shared with the Design team and [Spatial](https://www.figma.com/file/0Y3pKZj0tJWuleF12h5Sua/Spatial) and it's a way of describing the _variations_ of a given component.
219
+
220
+ **In Figma**, variants are represented as a matrix of options mapped / instrumented into the design itself.
221
+
222
+ **In UI Library**, variants are represented as a matrix of component props key:values mapped / instrumented into Styled Component css partials.
223
+
224
+ This isn't a new idea, or proprietary to Figma, but it is a built-in first class construct in that software. It's **not** built into the Styled Components as a first class construct, we are creating it here in the UI Library as a novel way to mirror that visual mapping in component builds. It's syntactic sugar, an opinion for working with fragments of style using Styled Components.
225
+
226
+ _It may be slightly more verbose with a bit of initial cognitive cost to represent component variations this way._ Let's commit to this pattern for now, to see it at scale, "in the wild". And let's also commit to continuing to evaluate it's usefulness. The goal is to offer a **semantic symmetry with design and build** that hopefuly translates to more consistent and stable products over a longer timeline.
227
+
228
+ ### Can I see an example of variants?
229
+
230
+ Yes! [Button](./src/components/Button), [Icon](./src/components/Icon), and [Toggle](./src/components/Toggle) all implement variants in the UI Library mirroring the variants in Figma.
231
+
232
+ ### How does it work?
233
+
234
+ ```tsx
235
+ // component.variants.ts
236
+ export const variants = {
237
+ propName: {
238
+ propValueA: css`
239
+ /* CSS... */
240
+ color: red;
241
+ `,
242
+ propValueB: css`
243
+ /* CSS... */
244
+ color: blue;
245
+ `,
246
+ },
247
+ };
248
+
249
+ // component.tsx
250
+ const Component = styled.div<{ propName: string }>`
251
+ /* Injects a CSS Partial matching prop name -> value */
252
+ ${getVariantCSS(variants, 'propName')};
253
+ `;
254
+
255
+ // Component with red text
256
+ <Component someProp="propValueA" />
257
+
258
+ // Component with blue text
259
+ <Component someProp="propValueB" />
260
+ ```
@@ -0,0 +1,37 @@
1
+ import { ButtonHTMLAttributes, FC, ReactNode } from 'react';
2
+ import { ButtonShape, ButtonSize, ButtonKind, ButtonLayout } from './button.variants';
3
+ declare type ButtonPropsWithLabel = {
4
+ label: string;
5
+ children?: never;
6
+ };
7
+ declare type ButtonPropsWithChildren = {
8
+ label?: never;
9
+ children: ReactNode;
10
+ };
11
+ export declare type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & (ButtonPropsWithLabel | ButtonPropsWithChildren) & {
12
+ label?: string;
13
+ href?: string;
14
+ size?: keyof typeof ButtonSize;
15
+ shape?: keyof typeof ButtonShape;
16
+ kind?: keyof typeof ButtonKind;
17
+ layout?: keyof typeof ButtonLayout;
18
+ children?: ReactNode;
19
+ };
20
+ /**
21
+ * Button as Anchor
22
+ * @example <Button as="a" href="https://..."/>
23
+ *
24
+ * Button with Label
25
+ * @example <Button label="..."/>
26
+ *
27
+ * Button with Child Element
28
+ * @example <Button><Child></Button>
29
+ */
30
+ export declare const Button: FC<ButtonProps>;
31
+ /**
32
+ * ## Button Variants
33
+ */
34
+ export declare const ButtonPrimary: FC<ButtonProps>;
35
+ export declare const ButtonSecondary: FC<ButtonProps>;
36
+ export declare const ButtonTertiary: FC<ButtonProps>;
37
+ export {};
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.ButtonTertiary = exports.ButtonSecondary = exports.ButtonPrimary = exports.Button = void 0;
18
+ const jsx_runtime_1 = require("react/jsx-runtime");
19
+ const styled_components_1 = __importDefault(require("styled-components"));
20
+ const Box_1 = require("../../layout/Box");
21
+ const helpers_1 = require("../../system/ThemeProvider/lib/helpers");
22
+ const button_variants_1 = require("./button.variants");
23
+ /**
24
+ * Button as Anchor
25
+ * @example <Button as="a" href="https://..."/>
26
+ *
27
+ * Button with Label
28
+ * @example <Button label="..."/>
29
+ *
30
+ * Button with Child Element
31
+ * @example <Button><Child></Button>
32
+ */
33
+ const Button = (_a) => {
34
+ var { label, children, size = 'base', shape = 'square', kind = 'primary', layout = 'fit', href } = _a, buttonProps = __rest(_a, ["label", "children", "size", "shape", "kind", "layout", "href"]);
35
+ return (jsx_runtime_1.jsx(ButtonElement, Object.assign({ as: href ? 'a' : 'button', size: size, shape: shape, kind: kind, layout: layout }, buttonProps, { children: label ? jsx_runtime_1.jsx(ButtonLabel, { children: label }, void 0) : children }), void 0));
36
+ };
37
+ exports.Button = Button;
38
+ const ButtonElement = styled_components_1.default.button `
39
+ /**
40
+ * 1. Initialize local variables with reasonable defaults
41
+ */
42
+ --color-background: ${({ theme }) => theme.palette.primaryBg};
43
+ --color-foreground: ${({ theme }) => theme.palette.primaryColor};
44
+
45
+ /**
46
+ * 2. Inject variants -- ? What are Variants
47
+ */
48
+ ${helpers_1.getVariantCSS(button_variants_1.variants, button_variants_1.Variant.size)}
49
+ ${helpers_1.getVariantCSS(button_variants_1.variants, button_variants_1.Variant.shape)}
50
+ ${helpers_1.getVariantCSS(button_variants_1.variants, button_variants_1.Variant.kind)}
51
+ ${helpers_1.getVariantCSS(button_variants_1.variants, button_variants_1.Variant.layout)}
52
+
53
+ /**
54
+ * 3. Component Build
55
+ */
56
+ background: var(--color-background);
57
+ color: var(--color-foreground);
58
+
59
+ display: inline-flex;
60
+ border: none;
61
+ outline: none;
62
+ text-decoration: none;
63
+ white-space: nowrap;
64
+ line-height: ${({ theme }) => theme.lineHeight.ui};
65
+ font-weight: ${({ theme }) => theme.fontWeight.bold};
66
+
67
+ &:focus,
68
+ &:active {
69
+ box-shadow: 0 0 0 2px ${({ theme }) => theme._color.black30},
70
+ 0 0 0 2px var(--color-background);
71
+ }
72
+
73
+ &:not(:disabled) {
74
+ cursor: pointer;
75
+ }
76
+ `;
77
+ const ButtonLabel = styled_components_1.default(Box_1.Box).attrs({
78
+ alignItems: 'center',
79
+ justifyContent: 'center',
80
+ }) `
81
+ padding: ${({ theme }) => `0 ${theme.px.xsmall}`};
82
+ `;
83
+ /**
84
+ * ## Button Variants
85
+ */
86
+ const ButtonPrimary = (props) => (jsx_runtime_1.jsx(exports.Button, Object.assign({}, props, { kind: "primary" }), void 0));
87
+ exports.ButtonPrimary = ButtonPrimary;
88
+ const ButtonSecondary = (props) => (jsx_runtime_1.jsx(exports.Button, Object.assign({}, props, { kind: "secondary" }), void 0));
89
+ exports.ButtonSecondary = ButtonSecondary;
90
+ const ButtonTertiary = (props) => (jsx_runtime_1.jsx(exports.Button, Object.assign({}, props, { kind: "tertiary" }), void 0));
91
+ exports.ButtonTertiary = ButtonTertiary;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Define all Button Variants here in one place.
3
+ * Variants should match the variants in Figma
4
+ */
5
+ export declare const Variant: {
6
+ readonly shape: "shape";
7
+ readonly size: "size";
8
+ readonly kind: "kind";
9
+ readonly layout: "layout";
10
+ };
11
+ /**
12
+ * Button Type -- Describes the "role" of a button
13
+ */
14
+ export declare const ButtonKind: {
15
+ readonly primary: "primary";
16
+ readonly secondary: "secondary";
17
+ readonly tertiary: "tertiary";
18
+ };
19
+ export declare type ButtonKindType = keyof typeof ButtonKind;
20
+ /**
21
+ * Button Size
22
+ */
23
+ export declare const ButtonSize: {
24
+ readonly small: "small";
25
+ readonly base: "base";
26
+ readonly large: "large";
27
+ };
28
+ export declare type ButtonSizeType = keyof typeof ButtonSize;
29
+ /**
30
+ * Button Width
31
+ */
32
+ export declare const ButtonLayout: {
33
+ readonly fit: "fit";
34
+ readonly full: "full";
35
+ };
36
+ export declare type ButtonLayoutType = keyof typeof ButtonLayout;
37
+ /**
38
+ * Button Shape
39
+ */
40
+ export declare const ButtonShape: {
41
+ readonly square: "square";
42
+ readonly pill: "pill";
43
+ };
44
+ export declare type ButtonShapeType = keyof typeof ButtonShape;
45
+ export declare const variants: {
46
+ readonly size: {
47
+ readonly base: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
48
+ readonly small: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
49
+ readonly large: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
50
+ };
51
+ readonly shape: {
52
+ readonly square: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
53
+ readonly pill: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
54
+ };
55
+ readonly layout: {
56
+ readonly fit: import("styled-components").FlattenSimpleInterpolation;
57
+ readonly full: import("styled-components").FlattenSimpleInterpolation;
58
+ };
59
+ readonly kind: {
60
+ readonly primary: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
61
+ readonly secondary: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
62
+ readonly tertiary: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
63
+ };
64
+ };
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.variants = exports.ButtonShape = exports.ButtonLayout = exports.ButtonSize = exports.ButtonKind = exports.Variant = void 0;
4
+ const styled_components_1 = require("styled-components");
5
+ /**
6
+ * Define all Button Variants here in one place.
7
+ * Variants should match the variants in Figma
8
+ */
9
+ exports.Variant = {
10
+ shape: 'shape',
11
+ size: 'size',
12
+ kind: 'kind',
13
+ layout: 'layout',
14
+ };
15
+ /**
16
+ * Button Type -- Describes the "role" of a button
17
+ */
18
+ exports.ButtonKind = {
19
+ primary: 'primary',
20
+ secondary: 'secondary',
21
+ tertiary: 'tertiary',
22
+ };
23
+ /**
24
+ * Button Size
25
+ */
26
+ exports.ButtonSize = {
27
+ small: 'small',
28
+ base: 'base',
29
+ large: 'large',
30
+ };
31
+ /**
32
+ * Button Width
33
+ */
34
+ exports.ButtonLayout = {
35
+ fit: 'fit',
36
+ full: 'full',
37
+ };
38
+ /**
39
+ * Button Shape
40
+ */
41
+ exports.ButtonShape = {
42
+ square: 'square',
43
+ pill: 'pill',
44
+ };
45
+ exports.variants = {
46
+ [exports.Variant.size]: {
47
+ [exports.ButtonSize.base]: styled_components_1.css `
48
+ padding: ${({ theme }) => theme.px.large};
49
+ font-size: ${({ theme }) => theme.fontSize.xlarge};
50
+ `,
51
+ [exports.ButtonSize.small]: styled_components_1.css `
52
+ padding: ${({ theme }) => theme.px.small};
53
+ font-size: ${({ theme }) => theme.fontSize.base};
54
+ `,
55
+ [exports.ButtonSize.large]: styled_components_1.css `
56
+ padding: ${({ theme }) => theme.px.xlarge};
57
+ font-size: ${({ theme }) => theme.fontSize.xxxlarge};
58
+ `,
59
+ },
60
+ [exports.Variant.shape]: {
61
+ [exports.ButtonShape.square]: styled_components_1.css `
62
+ border-radius: ${({ theme }) => theme.radius.base};
63
+ `,
64
+ [exports.ButtonShape.pill]: styled_components_1.css `
65
+ border-radius: ${({ theme }) => theme.radius.pill};
66
+ `,
67
+ },
68
+ [exports.Variant.layout]: {
69
+ [exports.ButtonLayout.fit]: styled_components_1.css `
70
+ width: fit-content;
71
+ `,
72
+ [exports.ButtonLayout.full]: styled_components_1.css `
73
+ width: 100%;
74
+ `,
75
+ },
76
+ [exports.Variant.kind]: {
77
+ [exports.ButtonKind.primary]: styled_components_1.css `
78
+ --color-background: ${({ theme }) => theme.palette.primaryBg};
79
+ --color-foreground: ${({ theme }) => theme.palette.primaryColor};
80
+
81
+ &:disabled {
82
+ --color-background: ${({ theme }) => theme.palette.primaryDisabledBg};
83
+ --color-foreground: ${({ theme }) => theme.palette.primaryDisabledColor};
84
+ }
85
+ `,
86
+ [exports.ButtonKind.secondary]: styled_components_1.css `
87
+ --color-background: ${({ theme }) => theme.palette.secondaryBg};
88
+ --color-foreground: ${({ theme }) => theme.palette.secondaryColor};
89
+
90
+ &:disabled {
91
+ --color-background: ${({ theme }) => theme.palette.secondaryDisabledBg};
92
+ --color-foreground: ${({ theme }) => theme.palette.secondaryDisabledColor};
93
+ }
94
+ `,
95
+ [exports.ButtonKind.tertiary]: styled_components_1.css `
96
+ --color-background: ${({ theme }) => theme.palette.tertiaryBg};
97
+ --color-foreground: ${({ theme }) => theme.palette.tertiaryColor};
98
+
99
+ &:disabled {
100
+ --color-background: ${({ theme }) => theme.palette.tertiaryDisabledBg};
101
+ --color-foreground: ${({ theme }) => theme.palette.tertiaryDisabledColor};
102
+ }
103
+ `,
104
+ },
105
+ };
@@ -0,0 +1,2 @@
1
+ export * from './button';
2
+ export * from './button.variants';
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./button"), exports);
14
+ __exportStar(require("./button.variants"), exports);
@@ -0,0 +1,15 @@
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
+ import { IconSizeType, IconType } from '../../system/ThemeProvider/lib/types';
3
+ export declare type PropsWithIcon = {
4
+ icon: IconType;
5
+ children?: never;
6
+ };
7
+ export declare type PropsWithChild = {
8
+ icon?: never;
9
+ children: ReactNode;
10
+ };
11
+ export declare type IconProps = HTMLAttributes<HTMLDivElement> & (PropsWithIcon | PropsWithChild) & {
12
+ size?: IconSizeType;
13
+ containerSize?: IconSizeType;
14
+ };
15
+ export declare const Icon: import("styled-components").StyledComponent<({ icon, children, size, containerSize, ...props }: IconProps) => JSX.Element, import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Icon = void 0;
18
+ const jsx_runtime_1 = require("react/jsx-runtime");
19
+ const styled_components_1 = __importDefault(require("styled-components"));
20
+ const Box_1 = require("../../layout/Box");
21
+ const ThemeProvider_1 = require("../../system/ThemeProvider");
22
+ const constants_1 = require("../../system/ThemeProvider/lib/constants");
23
+ const icon_variants_1 = require("./icon.variants");
24
+ exports.Icon = styled_components_1.default((_a) => {
25
+ var { icon, children, size = 'base', containerSize } = _a, props = __rest(_a, ["icon", "children", "size", "containerSize"]);
26
+ return (jsx_runtime_1.jsx(IconBox, Object.assign({}, props, { iconSize: size, containerSize: containerSize || size, justifyContent: "center", alignItems: "center" }, { children: icon ? jsx_runtime_1.jsx(IconSvg, { icon: icon }, void 0) : children }), void 0));
27
+ }) ``;
28
+ const IconSvg = styled_components_1.default((_a) => {
29
+ var { icon } = _a, props = __rest(_a, ["icon"]);
30
+ const SVG = constants_1.IconSet[icon];
31
+ return jsx_runtime_1.jsx(SVG, Object.assign({}, props), void 0);
32
+ }) ``;
33
+ const IconBox = styled_components_1.default(Box_1.Box) `
34
+ /**
35
+ * 1. Initialize local variables with reasonable defaults
36
+ */
37
+ --px-default: ${({ theme }) => theme.iconSize.base};
38
+
39
+ /**
40
+ * 2. Inject variants -- ? What are Variants
41
+ */
42
+ ${ThemeProvider_1.getVariantCSS(icon_variants_1.variants, icon_variants_1.Variant.containerSize)}
43
+ ${ThemeProvider_1.getVariantCSS(icon_variants_1.variants, icon_variants_1.Variant.iconSize)}
44
+
45
+ width: var(--px-container, var(--px-default));
46
+ height: var(--px-container, var(--px-default));
47
+
48
+ /* SVG Asset */
49
+ & > *,
50
+ ${IconSvg} {
51
+ display: block;
52
+ width: var(--px-icon, var(--px-default));
53
+ height: var(--px-icon, var(--px-default));
54
+ border-radius: inherit;
55
+ }
56
+ `;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Define all Button Variants here in one place.
3
+ * Variants should match the variants in Figma
4
+ */
5
+ export declare const Variant: {
6
+ readonly iconSize: "iconSize";
7
+ readonly containerSize: "containerSize";
8
+ };
9
+ export declare const variants: {
10
+ readonly iconSize: {
11
+ readonly xsmall: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
12
+ readonly small: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
13
+ readonly base: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
14
+ readonly large: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
15
+ readonly xlarge: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
16
+ readonly xxlarge: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
17
+ readonly xxxlarge: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
18
+ };
19
+ readonly containerSize: {
20
+ readonly xsmall: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
21
+ readonly small: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
22
+ readonly base: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
23
+ readonly large: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
24
+ readonly xlarge: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
25
+ readonly xxlarge: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
26
+ readonly xxxlarge: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
27
+ };
28
+ };