@digitalpromise/design 0.3.0
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.
- package/README.md +209 -0
- package/dist/css/variables.css +100 -0
- package/dist/digitalpromise-design.js +21 -0
- package/dist/digitalpromise-design.umd.cjs +1 -0
- package/dist/scss/_variables.scss +97 -0
- package/dist/style.css +1 -0
- package/package.json +48 -0
- package/src/components/Button/Button.stories.ts +35 -0
- package/src/components/Button/Button.tsx +48 -0
- package/src/components/Button/button.css +93 -0
package/README.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# React + TypeScript + Vite
|
|
2
|
+
|
|
3
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
+
|
|
5
|
+
Currently, two official plugins are available:
|
|
6
|
+
|
|
7
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
|
|
8
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
+
|
|
10
|
+
## Expanding the ESLint configuration
|
|
11
|
+
|
|
12
|
+
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
|
|
13
|
+
|
|
14
|
+
- Configure the top-level `parserOptions` property like this:
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
parserOptions: {
|
|
18
|
+
ecmaVersion: 'latest',
|
|
19
|
+
sourceType: 'module',
|
|
20
|
+
project: ['./tsconfig.json', './tsconfig.node.json'],
|
|
21
|
+
tsconfigRootDir: __dirname,
|
|
22
|
+
},
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
|
|
26
|
+
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
|
|
27
|
+
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
|
|
28
|
+
|
|
29
|
+
## Basic Style Dictionary
|
|
30
|
+
|
|
31
|
+
This example code is bare-bones to show you what this framework can do. If you have the style-dictionary module installed globally, you can `cd` into this directory and run:
|
|
32
|
+
```bash
|
|
33
|
+
style-dictionary build
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
You should see something like this output:
|
|
37
|
+
```
|
|
38
|
+
Copying starter files...
|
|
39
|
+
|
|
40
|
+
Source style dictionary starter files created!
|
|
41
|
+
|
|
42
|
+
Running `style-dictionary build` for the first time to generate build artifacts.
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
scss
|
|
46
|
+
✔︎ build/scss/_variables.scss
|
|
47
|
+
|
|
48
|
+
android
|
|
49
|
+
✔︎ build/android/font_dimens.xml
|
|
50
|
+
✔︎ build/android/colors.xml
|
|
51
|
+
|
|
52
|
+
compose
|
|
53
|
+
✔︎ build/compose/StyleDictionaryColor.kt
|
|
54
|
+
✔︎ build/compose/StyleDictionarySize.kt
|
|
55
|
+
|
|
56
|
+
ios
|
|
57
|
+
✔︎ build/ios/StyleDictionaryColor.h
|
|
58
|
+
✔︎ build/ios/StyleDictionaryColor.m
|
|
59
|
+
✔︎ build/ios/StyleDictionarySize.h
|
|
60
|
+
✔︎ build/ios/StyleDictionarySize.m
|
|
61
|
+
|
|
62
|
+
ios-swift
|
|
63
|
+
✔︎ build/ios-swift/StyleDictionary.swift
|
|
64
|
+
|
|
65
|
+
ios-swift-separate-enums
|
|
66
|
+
✔︎ build/ios-swift/StyleDictionaryColor.swift
|
|
67
|
+
✔︎ build/ios-swift/StyleDictionarySize.swift
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Good for you! You have now built your first style dictionary! Moving on, take a look at what we have built. This should have created a build directory and it should look like this:
|
|
71
|
+
```
|
|
72
|
+
├── README.md
|
|
73
|
+
├── config.json
|
|
74
|
+
├── tokens/
|
|
75
|
+
│ ├── color/
|
|
76
|
+
│ ├── base.json
|
|
77
|
+
│ ├── font.json
|
|
78
|
+
│ ├── size/
|
|
79
|
+
│ ├── font.json
|
|
80
|
+
├── build/
|
|
81
|
+
│ ├── android/
|
|
82
|
+
│ ├── font_dimens.xml
|
|
83
|
+
│ ├── colors.xml
|
|
84
|
+
│ ├── compose/
|
|
85
|
+
│ ├── StyleDictionaryColor.kt
|
|
86
|
+
│ ├── StyleDictionarySize.kt
|
|
87
|
+
│ ├── scss/
|
|
88
|
+
│ ├── _variables.scss
|
|
89
|
+
│ ├── ios/
|
|
90
|
+
│ ├── StyleDictionaryColor.h
|
|
91
|
+
│ ├── StyleDictionaryColor.m
|
|
92
|
+
│ ├── StyleDictionarySize.h
|
|
93
|
+
│ ├── StyleDictionarySize.m
|
|
94
|
+
│ ├── ios-swift/
|
|
95
|
+
│ ├── StyleDictionary.swift
|
|
96
|
+
│ ├── StyleDictionaryColor.swift
|
|
97
|
+
│ ├── StyleDictionarySize.swift
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
If you open `config.json` you will see there are 5 platforms defined: scss, android, compose, ios, and ios-swift. Each platform has a transformGroup, buildPath, and files. The buildPath and files of the platform should match up to the files what were built. The files built should look like these:
|
|
101
|
+
|
|
102
|
+
**Android**
|
|
103
|
+
```xml
|
|
104
|
+
<!-- font_dimens.xml -->
|
|
105
|
+
<resources>
|
|
106
|
+
<dimen name="size_font_small">12.00sp</dimen>
|
|
107
|
+
<dimen name="size_font_medium">16.00sp</dimen>
|
|
108
|
+
<dimen name="size_font_large">32.00sp</dimen>
|
|
109
|
+
<dimen name="size_font_base">16.00sp</dimen>
|
|
110
|
+
</resources>
|
|
111
|
+
|
|
112
|
+
<!-- colors.xml -->
|
|
113
|
+
<resources>
|
|
114
|
+
<color name="color_base_gray_light">#ffcccccc</color>
|
|
115
|
+
<color name="color_base_gray_medium">#ff999999</color>
|
|
116
|
+
<color name="color_base_gray_dark">#ff111111</color>
|
|
117
|
+
<color name="color_base_red">#ffff0000</color>
|
|
118
|
+
<color name="color_base_green">#ff00ff00</color>
|
|
119
|
+
<color name="color_font_base">#ffff0000</color>
|
|
120
|
+
<color name="color_font_secondary">#ff00ff00</color>
|
|
121
|
+
<color name="color_font_tertiary">#ffcccccc</color>
|
|
122
|
+
</resources>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Compose**
|
|
126
|
+
```kotlin
|
|
127
|
+
object StyleDictionaryColor {
|
|
128
|
+
val colorBaseGrayDark = Color(0xff111111)
|
|
129
|
+
val colorBaseGrayLight = Color(0xffcccccc)
|
|
130
|
+
val colorBaseGrayMedium = Color(0xff999999)
|
|
131
|
+
val colorBaseGreen = Color(0xff00ff00)
|
|
132
|
+
val colorBaseRed = Color(0xffff0000)
|
|
133
|
+
val colorFontBase = Color(0xffff0000)
|
|
134
|
+
val colorFontSecondary = Color(0xff00ff00)
|
|
135
|
+
val colorFontTertiary = Color(0xffcccccc)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
object StyleDictionarySize {
|
|
139
|
+
/** the base size of the font */
|
|
140
|
+
val sizeFontBase = 16.00.sp
|
|
141
|
+
/** the large size of the font */
|
|
142
|
+
val sizeFontLarge = 32.00.sp
|
|
143
|
+
/** the medium size of the font */
|
|
144
|
+
val sizeFontMedium = 16.00.sp
|
|
145
|
+
/** the small size of the font */
|
|
146
|
+
val sizeFontSmall = 12.00.sp
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**SCSS**
|
|
151
|
+
```scss
|
|
152
|
+
// variables.scss
|
|
153
|
+
$color-base-gray-light: #cccccc;
|
|
154
|
+
$color-base-gray-medium: #999999;
|
|
155
|
+
$color-base-gray-dark: #111111;
|
|
156
|
+
$color-base-red: #ff0000;
|
|
157
|
+
$color-base-green: #00ff00;
|
|
158
|
+
$color-font-base: #ff0000;
|
|
159
|
+
$color-font-secondary: #00ff00;
|
|
160
|
+
$color-font-tertiary: #cccccc;
|
|
161
|
+
$size-font-small: 0.75rem;
|
|
162
|
+
$size-font-medium: 1rem;
|
|
163
|
+
$size-font-large: 2rem;
|
|
164
|
+
$size-font-base: 1rem;
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**iOS**
|
|
168
|
+
```objc
|
|
169
|
+
#import "StyleDictionaryColor.h"
|
|
170
|
+
|
|
171
|
+
@implementation StyleDictionaryColor
|
|
172
|
+
|
|
173
|
+
+ (UIColor *)color:(StyleDictionaryColorName)colorEnum{
|
|
174
|
+
return [[self values] objectAtIndex:colorEnum];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
+ (NSArray *)values {
|
|
178
|
+
static NSArray* colorArray;
|
|
179
|
+
static dispatch_once_t onceToken;
|
|
180
|
+
|
|
181
|
+
dispatch_once(&onceToken, ^{
|
|
182
|
+
colorArray = @[
|
|
183
|
+
[UIColor colorWithRed:0.800f green:0.800f blue:0.800f alpha:1.000f],
|
|
184
|
+
[UIColor colorWithRed:0.600f green:0.600f blue:0.600f alpha:1.000f],
|
|
185
|
+
[UIColor colorWithRed:0.067f green:0.067f blue:0.067f alpha:1.000f],
|
|
186
|
+
[UIColor colorWithRed:1.000f green:0.000f blue:0.000f alpha:1.000f],
|
|
187
|
+
[UIColor colorWithRed:0.000f green:1.000f blue:0.000f alpha:1.000f],
|
|
188
|
+
[UIColor colorWithRed:1.000f green:0.000f blue:0.000f alpha:1.000f],
|
|
189
|
+
[UIColor colorWithRed:0.000f green:1.000f blue:0.000f alpha:1.000f],
|
|
190
|
+
[UIColor colorWithRed:0.800f green:0.800f blue:0.800f alpha:1.000f]
|
|
191
|
+
];
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
return colorArray;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
@end
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Pretty nifty! This shows a few things happening:
|
|
201
|
+
1. The build system does a deep merge of all the token JSON files defined in the `source` attribute of `config.json`. This allows you to split up the token JSON files however you want. There are 2 JSON files with `color` as the top level key, but they get merged properly.
|
|
202
|
+
1. The build system resolves references to other design tokens. `{size.font.medium.value}` gets resolved properly.
|
|
203
|
+
1. The build system handles references to token values in other files as well as you can see in `tokens/color/font.json`.
|
|
204
|
+
|
|
205
|
+
Now let's make a change and see how that affects things. Open up `tokens/color/base.json` and change `"#111111"` to `"#000000"`. After you make that change, save the file and re-run the build command `style-dictionary build`. Open up the build files and take a look.
|
|
206
|
+
|
|
207
|
+
**Huzzah!**
|
|
208
|
+
|
|
209
|
+
Now go forth and create! Take a look at all the built-in [transforms](https://amzn.github.io/style-dictionary/#/transforms?id=pre-defined-transforms) and [formats](https://amzn.github.io/style-dictionary/#/formats?id=pre-defined-formats).
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Do not edit directly
|
|
3
|
+
* Generated on Thu, 08 Feb 2024 11:59:30 GMT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
:root {
|
|
7
|
+
--dpg-button-color-border: transparent;
|
|
8
|
+
--dpg-size-spacing-12: 22.5rem;
|
|
9
|
+
--dpg-size-spacing-11: 15rem;
|
|
10
|
+
--dpg-size-spacing-10: 6rem;
|
|
11
|
+
--dpg-size-spacing-9: 5rem;
|
|
12
|
+
--dpg-size-spacing-8: 4rem;
|
|
13
|
+
--dpg-size-spacing-7: 3rem;
|
|
14
|
+
--dpg-size-spacing-6: 2rem;
|
|
15
|
+
--dpg-size-spacing-5: 1.5rem;
|
|
16
|
+
--dpg-size-spacing-4: 1rem;
|
|
17
|
+
--dpg-size-spacing-3: 0.75rem;
|
|
18
|
+
--dpg-size-spacing-2: 0.5rem;
|
|
19
|
+
--dpg-size-spacing-1: 0.25rem;
|
|
20
|
+
--dpg-size-font-xxx-large: 4rem;
|
|
21
|
+
--dpg-size-font-xx-large: 3rem;
|
|
22
|
+
--dpg-size-font-x-large: 2rem;
|
|
23
|
+
--dpg-size-font-large: 1.5rem;
|
|
24
|
+
--dpg-size-font-medium-large: 1.25rem;
|
|
25
|
+
--dpg-size-font-medium: 1rem; /* The default font size. */
|
|
26
|
+
--dpg-size-font-small: 0.875rem; /* The smallest font size. */
|
|
27
|
+
--dpg-color-neutral-5: #000000;
|
|
28
|
+
--dpg-color-neutral-4: rgba(0, 0, 0, 0.45);
|
|
29
|
+
--dpg-color-neutral-3: rgba(0, 0, 0, 0.15);
|
|
30
|
+
--dpg-color-neutral-2: rgba(0, 0, 0, 0.08);
|
|
31
|
+
--dpg-color-neutral-1: #ffffff;
|
|
32
|
+
--dpg-color-teal-5: #17616e;
|
|
33
|
+
--dpg-color-teal-4: #1e7e90;
|
|
34
|
+
--dpg-color-teal-3: #259cb2;
|
|
35
|
+
--dpg-color-teal-2: #caeef4;
|
|
36
|
+
--dpg-color-teal-1: #eaf8fb;
|
|
37
|
+
--dpg-color-jade-5: #336647;
|
|
38
|
+
--dpg-color-jade-4: #40815a;
|
|
39
|
+
--dpg-color-jade-3: #4e9d6d;
|
|
40
|
+
--dpg-color-jade-2: #d4eadd;
|
|
41
|
+
--dpg-color-jade-1: #eef7f1;
|
|
42
|
+
--dpg-color-green-5: #50681d;
|
|
43
|
+
--dpg-color-green-4: #698826;
|
|
44
|
+
--dpg-color-green-3: #82a82f;
|
|
45
|
+
--dpg-color-green-2: #e6f1cd;
|
|
46
|
+
--dpg-color-green-1: #f5f9eb;
|
|
47
|
+
--dpg-color-orange-5: #9e5000;
|
|
48
|
+
--dpg-color-orange-4: #c86400;
|
|
49
|
+
--dpg-color-orange-3: #e3811c;
|
|
50
|
+
--dpg-color-orange-2: #f8dfc6;
|
|
51
|
+
--dpg-color-orange-1: #fcf2e8;
|
|
52
|
+
--dpg-color-red-5: #ab3916;
|
|
53
|
+
--dpg-color-red-4: #d0451b;
|
|
54
|
+
--dpg-color-red-3: #e45a2f;
|
|
55
|
+
--dpg-color-red-2: #f8d2c7;
|
|
56
|
+
--dpg-color-red-1: #fcede8;
|
|
57
|
+
--dpg-color-magenta-5: #743a61;
|
|
58
|
+
--dpg-color-magenta-4: #8f4777;
|
|
59
|
+
--dpg-color-magenta-3: #aa558e;
|
|
60
|
+
--dpg-color-magenta-2: #ead5e3;
|
|
61
|
+
--dpg-color-magenta-1: #f6eef4;
|
|
62
|
+
--dpg-color-violet-5: #693a73;
|
|
63
|
+
--dpg-color-violet-4: #81488e;
|
|
64
|
+
--dpg-color-violet-3: #9a55aa;
|
|
65
|
+
--dpg-color-violet-2: #e6d5ea;
|
|
66
|
+
--dpg-color-violet-1: #f5eef6;
|
|
67
|
+
--dpg-color-purple-5: #5a4280;
|
|
68
|
+
--dpg-color-purple-4: #6d509b;
|
|
69
|
+
--dpg-color-purple-3: #8164af;
|
|
70
|
+
--dpg-color-purple-2: #ddd5e9;
|
|
71
|
+
--dpg-color-purple-1: #f1eef6;
|
|
72
|
+
--dpg-color-indigo-5: #3a4d88;
|
|
73
|
+
--dpg-color-indigo-4: #465da5;
|
|
74
|
+
--dpg-color-indigo-3: #5a71b9;
|
|
75
|
+
--dpg-color-indigo-2: #d2d8ec;
|
|
76
|
+
--dpg-color-indigo-1: #eef2f9;
|
|
77
|
+
--dpg-color-blue-5: #246289;
|
|
78
|
+
--dpg-color-blue-4: #2a7aac;
|
|
79
|
+
--dpg-color-blue-3: #348ec7;
|
|
80
|
+
--dpg-color-blue-2: #cce3f2;
|
|
81
|
+
--dpg-color-blue-1: #ebf4fa;
|
|
82
|
+
--dpg-color-gray-5: #454545;
|
|
83
|
+
--dpg-color-gray-4: #777777;
|
|
84
|
+
--dpg-color-gray-3: #a3a3a3;
|
|
85
|
+
--dpg-color-gray-2: #e6e6e6;
|
|
86
|
+
--dpg-color-gray-1: #f4f4f4;
|
|
87
|
+
--dpg-button-size-border-radius: var(--dpg-size-spacing-5);
|
|
88
|
+
--dpg-button-size-padding-y: var(--dpg-size-spacing-3);
|
|
89
|
+
--dpg-button-size-padding-x: var(--dpg-size-spacing-5);
|
|
90
|
+
--dpg-size-font-base: var(--dpg-size-font-medium);
|
|
91
|
+
--dpg-color-contrast: var(--dpg-color-neutral-5); /* The default text color that contrasts against the base. */
|
|
92
|
+
--dpg-color-base: var(--dpg-color-neutral-1); /* The base background color for text content. */
|
|
93
|
+
--dpg-color-disabled: var(--dpg-color-gray-3); /* Color indicating an action is disabled. */
|
|
94
|
+
--dpg-color-danger-hover: var(--dpg-color-red-5);
|
|
95
|
+
--dpg-color-danger: var(--dpg-color-red-4); /* Color that highlights dangerous actions. */
|
|
96
|
+
--dpg-color-primary-hover: var(--dpg-color-blue-1);
|
|
97
|
+
--dpg-color-primary: var(--dpg-color-blue-4); /* Primary brand color. */
|
|
98
|
+
--dpg-button-color-background: var(--dpg-color-primary);
|
|
99
|
+
--dpg-button-color-text: var(--dpg-color-base);
|
|
100
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
2
|
+
const a = ({
|
|
3
|
+
variant: n = "solid",
|
|
4
|
+
danger: o = !1,
|
|
5
|
+
label: s,
|
|
6
|
+
...e
|
|
7
|
+
}) => {
|
|
8
|
+
const t = ["button", `button--${n}`];
|
|
9
|
+
return o && t.push("danger"), /* @__PURE__ */ u(
|
|
10
|
+
"button",
|
|
11
|
+
{
|
|
12
|
+
type: "button",
|
|
13
|
+
className: t.join(" "),
|
|
14
|
+
...e,
|
|
15
|
+
children: s
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
a as Button
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("react/jsx-runtime")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.DPGDesign={},e.jsxRuntime))})(this,function(e,t){"use strict";const f="",o=({variant:i="solid",danger:s=!1,label:u,...d})=>{const n=["button",`button--${i}`];return s&&n.push("danger"),t.jsx("button",{type:"button",className:n.join(" "),...d,children:u})};e.Button=o,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
|
|
2
|
+
// Do not edit directly
|
|
3
|
+
// Generated on Thu, 08 Feb 2024 11:59:30 GMT
|
|
4
|
+
|
|
5
|
+
$color-gray-1: #f4f4f4;
|
|
6
|
+
$color-gray-2: #e6e6e6;
|
|
7
|
+
$color-gray-3: #a3a3a3;
|
|
8
|
+
$color-gray-4: #777777;
|
|
9
|
+
$color-gray-5: #454545;
|
|
10
|
+
$color-blue-1: #ebf4fa;
|
|
11
|
+
$color-blue-2: #cce3f2;
|
|
12
|
+
$color-blue-3: #348ec7;
|
|
13
|
+
$color-blue-4: #2a7aac;
|
|
14
|
+
$color-blue-5: #246289;
|
|
15
|
+
$color-indigo-1: #eef2f9;
|
|
16
|
+
$color-indigo-2: #d2d8ec;
|
|
17
|
+
$color-indigo-3: #5a71b9;
|
|
18
|
+
$color-indigo-4: #465da5;
|
|
19
|
+
$color-indigo-5: #3a4d88;
|
|
20
|
+
$color-purple-1: #f1eef6;
|
|
21
|
+
$color-purple-2: #ddd5e9;
|
|
22
|
+
$color-purple-3: #8164af;
|
|
23
|
+
$color-purple-4: #6d509b;
|
|
24
|
+
$color-purple-5: #5a4280;
|
|
25
|
+
$color-violet-1: #f5eef6;
|
|
26
|
+
$color-violet-2: #e6d5ea;
|
|
27
|
+
$color-violet-3: #9a55aa;
|
|
28
|
+
$color-violet-4: #81488e;
|
|
29
|
+
$color-violet-5: #693a73;
|
|
30
|
+
$color-magenta-1: #f6eef4;
|
|
31
|
+
$color-magenta-2: #ead5e3;
|
|
32
|
+
$color-magenta-3: #aa558e;
|
|
33
|
+
$color-magenta-4: #8f4777;
|
|
34
|
+
$color-magenta-5: #743a61;
|
|
35
|
+
$color-red-1: #fcede8;
|
|
36
|
+
$color-red-2: #f8d2c7;
|
|
37
|
+
$color-red-3: #e45a2f;
|
|
38
|
+
$color-red-4: #d0451b;
|
|
39
|
+
$color-red-5: #ab3916;
|
|
40
|
+
$color-orange-1: #fcf2e8;
|
|
41
|
+
$color-orange-2: #f8dfc6;
|
|
42
|
+
$color-orange-3: #e3811c;
|
|
43
|
+
$color-orange-4: #c86400;
|
|
44
|
+
$color-orange-5: #9e5000;
|
|
45
|
+
$color-green-1: #f5f9eb;
|
|
46
|
+
$color-green-2: #e6f1cd;
|
|
47
|
+
$color-green-3: #82a82f;
|
|
48
|
+
$color-green-4: #698826;
|
|
49
|
+
$color-green-5: #50681d;
|
|
50
|
+
$color-jade-1: #eef7f1;
|
|
51
|
+
$color-jade-2: #d4eadd;
|
|
52
|
+
$color-jade-3: #4e9d6d;
|
|
53
|
+
$color-jade-4: #40815a;
|
|
54
|
+
$color-jade-5: #336647;
|
|
55
|
+
$color-teal-1: #eaf8fb;
|
|
56
|
+
$color-teal-2: #caeef4;
|
|
57
|
+
$color-teal-3: #259cb2;
|
|
58
|
+
$color-teal-4: #1e7e90;
|
|
59
|
+
$color-teal-5: #17616e;
|
|
60
|
+
$color-neutral-1: #ffffff;
|
|
61
|
+
$color-neutral-2: rgba(0, 0, 0, 0.08);
|
|
62
|
+
$color-neutral-3: rgba(0, 0, 0, 0.15);
|
|
63
|
+
$color-neutral-4: rgba(0, 0, 0, 0.45);
|
|
64
|
+
$color-neutral-5: #000000;
|
|
65
|
+
$color-primary: #2a7aac; // Primary brand color.
|
|
66
|
+
$color-primary-hover: #ebf4fa;
|
|
67
|
+
$color-danger: #d0451b; // Color that highlights dangerous actions.
|
|
68
|
+
$color-danger-hover: #ab3916;
|
|
69
|
+
$color-disabled: #a3a3a3; // Color indicating an action is disabled.
|
|
70
|
+
$color-base: #ffffff; // The base background color for text content.
|
|
71
|
+
$color-contrast: #000000; // The default text color that contrasts against the base.
|
|
72
|
+
$size-font-small: 0.875rem; // The smallest font size.
|
|
73
|
+
$size-font-medium: 1rem; // The default font size.
|
|
74
|
+
$size-font-medium-large: 1.25rem;
|
|
75
|
+
$size-font-large: 1.5rem;
|
|
76
|
+
$size-font-x-large: 2rem;
|
|
77
|
+
$size-font-xx-large: 3rem;
|
|
78
|
+
$size-font-xxx-large: 4rem;
|
|
79
|
+
$size-font-base: 1rem;
|
|
80
|
+
$size-spacing-1: 0.25rem;
|
|
81
|
+
$size-spacing-2: 0.5rem;
|
|
82
|
+
$size-spacing-3: 0.75rem;
|
|
83
|
+
$size-spacing-4: 1rem;
|
|
84
|
+
$size-spacing-5: 1.5rem;
|
|
85
|
+
$size-spacing-6: 2rem;
|
|
86
|
+
$size-spacing-7: 3rem;
|
|
87
|
+
$size-spacing-8: 4rem;
|
|
88
|
+
$size-spacing-9: 5rem;
|
|
89
|
+
$size-spacing-10: 6rem;
|
|
90
|
+
$size-spacing-11: 15rem;
|
|
91
|
+
$size-spacing-12: 22.5rem;
|
|
92
|
+
$button-color-text: #ffffff;
|
|
93
|
+
$button-color-background: #2a7aac;
|
|
94
|
+
$button-color-border: transparent;
|
|
95
|
+
$button-size-padding-x: 1.5rem;
|
|
96
|
+
$button-size-padding-y: 0.75rem;
|
|
97
|
+
$button-size-border-radius: 1.5rem;
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.button{background-color:var(--dpg-button-color-background);border-color:var(--dpg-button-color-border);border-radius:var(--dpg-button-size-border-radius);border-style:solid;border-width:2px;color:var(--dpg-button-color-text);display:inline-flex;justify-content:center;align-items:center;font-family:inherit;font-size:inherit;font-weight:600;padding:var(--dpg-button-size-padding-y) var(--dpg-button-size-padding-x);transition-property:background-color,color,border-color;transition-duration:.2s;transition-timing-function:ease}.button--outline{--dpg-button-color-background: var(--dpg-color-base);--dpg-button-color-text: var(--dpg-color-primary);--dpg-button-color-border: var(--dpg-color-primary)}.button--text{--dpg-button-color-background: none;--dpg-button-color-text: var(--dpg-color-primary);text-decoration:underline;padding-left:0;padding-right:0}.button--solid.danger{--dpg-button-color-background: var(--dpg-color-danger)}.button--outline.danger,.button--text.danger{--dpg-button-color-text: var(--dpg-color-danger)}.button--outline.danger{--dpg-button-color-border: var(--dpg-color-danger)}.button--solid[disabled]{--dpg-button-color-background: var(--dpg-color-disabled)}.button--outline[disabled],.button--text[disabled]{--dpg-button-color-text: var(--dpg-color-disabled)}.button--outline[disabled]{--dpg-button-color-border: var(--dpg-color-disabled)}.button--solid:hover,.button--solid:focus,.button--outline:hover,.button--outline:focus{--dpg-button-color-text: var(--dpg-color-primary);--dpg-button-color-background: var(--dpg-color-primary-hover);--dpg-button-color-border: var(--dpg-color-primary)}.button--text:hover,.button--text:focus{--dpg-button-color-text: var(--dpg-color-blue-5)}.button--solid.danger:hover,.button--solid.danger:focus{--dpg-button-color-background: var(--dpg-color-danger-hover)}.button--outline.danger:hover,.button--outline.danger:focus,.button--text.danger:hover,.button--text.danger:focus{--dpg-button-color-text: var(--dpg-color-danger-hover)}.button--outline.danger:hover,.button--outline.danger:focus{--button-bg-color: var(--dpg-color-red-1)}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@digitalpromise/design",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.3.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"src/components/**",
|
|
8
|
+
"dist/**"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"style-dictionary": "style-dictionary build",
|
|
12
|
+
"postbuild": "style-dictionary build",
|
|
13
|
+
"prestorybook": "style-dictionary build",
|
|
14
|
+
"prebuild-storybook": "style-dictionary build",
|
|
15
|
+
"dev": "vite",
|
|
16
|
+
"build": "tsc && vite build",
|
|
17
|
+
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
18
|
+
"preview": "vite preview",
|
|
19
|
+
"storybook": "storybook dev -p 6006",
|
|
20
|
+
"build-storybook": "storybook build"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"react": "^18.2.0",
|
|
24
|
+
"react-dom": "^18.2.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@storybook/addon-essentials": "^7.2.2",
|
|
28
|
+
"@storybook/addon-interactions": "^7.2.2",
|
|
29
|
+
"@storybook/addon-links": "^7.2.2",
|
|
30
|
+
"@storybook/blocks": "^7.2.2",
|
|
31
|
+
"@storybook/react": "^7.2.2",
|
|
32
|
+
"@storybook/react-vite": "^7.2.2",
|
|
33
|
+
"@storybook/testing-library": "^0.2.0",
|
|
34
|
+
"@types/react": "^18.2.15",
|
|
35
|
+
"@types/react-dom": "^18.2.7",
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
37
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
38
|
+
"@vitejs/plugin-react-swc": "^3.3.2",
|
|
39
|
+
"eslint": "^8.45.0",
|
|
40
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
41
|
+
"eslint-plugin-react-refresh": "^0.4.3",
|
|
42
|
+
"eslint-plugin-storybook": "^0.6.13",
|
|
43
|
+
"storybook": "^7.2.2",
|
|
44
|
+
"style-dictionary": "^3.8.0",
|
|
45
|
+
"typescript": "^5.0.2",
|
|
46
|
+
"vite": "^4.4.5"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import { Button } from './Button';
|
|
4
|
+
|
|
5
|
+
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Button',
|
|
8
|
+
component: Button,
|
|
9
|
+
parameters: {
|
|
10
|
+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/react/configure/story-layout
|
|
11
|
+
layout: 'centered',
|
|
12
|
+
},
|
|
13
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
|
|
14
|
+
tags: ['autodocs'],
|
|
15
|
+
args: {
|
|
16
|
+
disabled: false
|
|
17
|
+
}
|
|
18
|
+
} satisfies Meta<typeof Button>;
|
|
19
|
+
|
|
20
|
+
export default meta;
|
|
21
|
+
type Story = StoryObj<typeof meta>;
|
|
22
|
+
|
|
23
|
+
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
|
|
24
|
+
export const Primary: Story = {
|
|
25
|
+
args: {
|
|
26
|
+
label: 'Button',
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const Danger: Story = {
|
|
31
|
+
args: {
|
|
32
|
+
label: 'Dangerous action!',
|
|
33
|
+
danger: true
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import './button.css';
|
|
2
|
+
|
|
3
|
+
interface ButtonProps {
|
|
4
|
+
/**
|
|
5
|
+
* Which of three styles of button to display
|
|
6
|
+
*/
|
|
7
|
+
variant?: 'solid' | 'outline' | 'text';
|
|
8
|
+
/**
|
|
9
|
+
* Button initiates a dangerous action
|
|
10
|
+
*/
|
|
11
|
+
danger?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Button contents
|
|
14
|
+
*/
|
|
15
|
+
label: string;
|
|
16
|
+
/**
|
|
17
|
+
* Optional click handler
|
|
18
|
+
*/
|
|
19
|
+
onClick?: () => void;
|
|
20
|
+
/**
|
|
21
|
+
* Add disabled attribute
|
|
22
|
+
*/
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Primary UI component for user interaction
|
|
28
|
+
*/
|
|
29
|
+
export const Button = ({
|
|
30
|
+
variant = 'solid',
|
|
31
|
+
danger = false,
|
|
32
|
+
label,
|
|
33
|
+
...props
|
|
34
|
+
}: ButtonProps) => {
|
|
35
|
+
const classname = ['button', `button--${variant}`];
|
|
36
|
+
if (danger) {
|
|
37
|
+
classname.push('danger');
|
|
38
|
+
}
|
|
39
|
+
return (
|
|
40
|
+
<button
|
|
41
|
+
type="button"
|
|
42
|
+
className={classname.join(' ')}
|
|
43
|
+
{...props}
|
|
44
|
+
>
|
|
45
|
+
{label}
|
|
46
|
+
</button>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
.button {
|
|
2
|
+
/** Default solid style **/
|
|
3
|
+
background-color: var(--dpg-button-color-background);
|
|
4
|
+
border-color: var(--dpg-button-color-border);
|
|
5
|
+
border-radius: var(--dpg-button-size-border-radius);
|
|
6
|
+
border-style: solid;
|
|
7
|
+
border-width: 2px;
|
|
8
|
+
color: var(--dpg-button-color-text);
|
|
9
|
+
|
|
10
|
+
/** Base button styles **/
|
|
11
|
+
display: inline-flex;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
align-items: center;
|
|
14
|
+
font-family: inherit;
|
|
15
|
+
font-size: inherit;
|
|
16
|
+
font-weight: 600;
|
|
17
|
+
padding: var(--dpg-button-size-padding-y) var(--dpg-button-size-padding-x);
|
|
18
|
+
transition-property: background-color, color, border-color;
|
|
19
|
+
transition-duration: 200ms;
|
|
20
|
+
transition-timing-function: ease;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Outline style token overrides **/
|
|
24
|
+
.button--outline {
|
|
25
|
+
--dpg-button-color-background: var(--dpg-color-base);
|
|
26
|
+
--dpg-button-color-text: var(--dpg-color-primary);
|
|
27
|
+
--dpg-button-color-border: var(--dpg-color-primary);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.button--text {
|
|
31
|
+
--dpg-button-color-background: none;
|
|
32
|
+
--dpg-button-color-text: var(--dpg-color-primary);
|
|
33
|
+
text-decoration: underline;
|
|
34
|
+
padding-left: 0px;
|
|
35
|
+
padding-right: 0px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.button--solid.danger {
|
|
39
|
+
--dpg-button-color-background: var(--dpg-color-danger);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.button--outline.danger,
|
|
43
|
+
.button--text.danger {
|
|
44
|
+
--dpg-button-color-text: var(--dpg-color-danger);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.button--outline.danger {
|
|
48
|
+
--dpg-button-color-border: var(--dpg-color-danger);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.button--solid[disabled] {
|
|
52
|
+
--dpg-button-color-background: var(--dpg-color-disabled);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.button--outline[disabled],
|
|
56
|
+
.button--text[disabled] {
|
|
57
|
+
--dpg-button-color-text: var(--dpg-color-disabled);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.button--outline[disabled] {
|
|
61
|
+
--dpg-button-color-border: var(--dpg-color-disabled);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.button--solid:hover,
|
|
65
|
+
.button--solid:focus,
|
|
66
|
+
.button--outline:hover,
|
|
67
|
+
.button--outline:focus {
|
|
68
|
+
--dpg-button-color-text: var(--dpg-color-primary);
|
|
69
|
+
--dpg-button-color-background: var(--dpg-color-primary-hover);
|
|
70
|
+
--dpg-button-color-border: var(--dpg-color-primary);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.button--text:hover,
|
|
74
|
+
.button--text:focus {
|
|
75
|
+
--dpg-button-color-text: var(--dpg-color-blue-5);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.button--solid.danger:hover,
|
|
79
|
+
.button--solid.danger:focus {
|
|
80
|
+
--dpg-button-color-background: var(--dpg-color-danger-hover);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.button--outline.danger:hover,
|
|
84
|
+
.button--outline.danger:focus,
|
|
85
|
+
.button--text.danger:hover,
|
|
86
|
+
.button--text.danger:focus {
|
|
87
|
+
--dpg-button-color-text: var(--dpg-color-danger-hover);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.button--outline.danger:hover,
|
|
91
|
+
.button--outline.danger:focus {
|
|
92
|
+
--button-bg-color: var(--dpg-color-red-1);
|
|
93
|
+
}
|