@bgord/design 0.4.0 → 0.7.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 +19 -171
- package/dist/backgrounds-generator.d.ts +10 -0
- package/dist/design.cjs.development.js +138 -3
- package/dist/design.cjs.development.js.map +1 -1
- package/dist/design.cjs.production.min.js +1 -1
- package/dist/design.cjs.production.min.js.map +1 -1
- package/dist/design.esm.js +138 -3
- package/dist/design.esm.js.map +1 -1
- package/dist/font-weight-generator.d.ts +10 -0
- package/dist/generator.d.ts +4 -1
- package/dist/line-height-generator.d.ts +10 -0
- package/dist/main.css +132 -52
- package/dist/main.min.css +1 -1
- package/dist/tokens.d.ts +6 -0
- package/package.json +1 -1
- package/src/backgrounds-generator.ts +32 -0
- package/src/displays-generator.ts +5 -1
- package/src/font-weight-generator.ts +32 -0
- package/src/generate-css.ts +19 -3
- package/src/generator.ts +6 -0
- package/src/line-height-generator.ts +32 -0
- package/src/tokens.ts +47 -0
package/README.md
CHANGED
|
@@ -1,181 +1,29 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @bgord/design
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Placement:
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- displays
|
|
6
|
+
- flex-directions
|
|
7
|
+
- flex-wraps
|
|
8
|
+
- axis-placements
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
Spacing:
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
- margins
|
|
13
|
+
- paddings
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
- widhts
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
Position:
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
```
|
|
19
|
+
- postions
|
|
20
|
+
- z-index
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
Text:
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
- font-size
|
|
25
|
+
- font-weight
|
|
26
|
+
- line-height
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Run inside another terminal:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
yarn storybook
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
This loads the stories from `./stories`.
|
|
32
|
-
|
|
33
|
-
> NOTE: Stories should reference the components as if using the library, similar to the example playground. This means importing from the root project directory. This has been aliased in the tsconfig and the storybook webpack config as a helper.
|
|
34
|
-
|
|
35
|
-
### Example
|
|
36
|
-
|
|
37
|
-
Then run the example inside another:
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
cd example
|
|
41
|
-
npm i # or yarn to install dependencies
|
|
42
|
-
npm start # or yarn start
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
The default example imports and live reloads whatever is in `/dist`, so if you are seeing an out of date component, make sure TSDX is running in watch mode like we recommend above. **No symlinking required**, we use [Parcel's aliasing](https://parceljs.org/module_resolution.html#aliases).
|
|
46
|
-
|
|
47
|
-
To do a one-off build, use `npm run build` or `yarn build`.
|
|
48
|
-
|
|
49
|
-
To run tests, use `npm test` or `yarn test`.
|
|
50
|
-
|
|
51
|
-
## Configuration
|
|
52
|
-
|
|
53
|
-
Code quality is set up for you with `prettier`, `husky`, and `lint-staged`. Adjust the respective fields in `package.json` accordingly.
|
|
54
|
-
|
|
55
|
-
### Jest
|
|
56
|
-
|
|
57
|
-
Jest tests are set up to run with `npm test` or `yarn test`.
|
|
58
|
-
|
|
59
|
-
### Bundle analysis
|
|
60
|
-
|
|
61
|
-
Calculates the real cost of your library using [size-limit](https://github.com/ai/size-limit) with `npm run size` and visulize it with `npm run analyze`.
|
|
62
|
-
|
|
63
|
-
#### Setup Files
|
|
64
|
-
|
|
65
|
-
This is the folder structure we set up for you:
|
|
66
|
-
|
|
67
|
-
```txt
|
|
68
|
-
/example
|
|
69
|
-
index.html
|
|
70
|
-
index.tsx # test your component here in a demo app
|
|
71
|
-
package.json
|
|
72
|
-
tsconfig.json
|
|
73
|
-
/src
|
|
74
|
-
index.tsx # EDIT THIS
|
|
75
|
-
/test
|
|
76
|
-
blah.test.tsx # EDIT THIS
|
|
77
|
-
/stories
|
|
78
|
-
Thing.stories.tsx # EDIT THIS
|
|
79
|
-
/.storybook
|
|
80
|
-
main.js
|
|
81
|
-
preview.js
|
|
82
|
-
.gitignore
|
|
83
|
-
package.json
|
|
84
|
-
README.md # EDIT THIS
|
|
85
|
-
tsconfig.json
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
#### React Testing Library
|
|
89
|
-
|
|
90
|
-
We do not set up `react-testing-library` for you yet, we welcome contributions and documentation on this.
|
|
91
|
-
|
|
92
|
-
### Rollup
|
|
93
|
-
|
|
94
|
-
TSDX uses [Rollup](https://rollupjs.org) as a bundler and generates multiple rollup configs for various module formats and build settings. See [Optimizations](#optimizations) for details.
|
|
95
|
-
|
|
96
|
-
### TypeScript
|
|
97
|
-
|
|
98
|
-
`tsconfig.json` is set up to interpret `dom` and `esnext` types, as well as `react` for `jsx`. Adjust according to your needs.
|
|
99
|
-
|
|
100
|
-
## Continuous Integration
|
|
101
|
-
|
|
102
|
-
### GitHub Actions
|
|
103
|
-
|
|
104
|
-
Two actions are added by default:
|
|
105
|
-
|
|
106
|
-
- `main` which installs deps w/ cache, lints, tests, and builds on all pushes against a Node and OS matrix
|
|
107
|
-
- `size` which comments cost comparison of your library on every pull request using [size-limit](https://github.com/ai/size-limit)
|
|
108
|
-
|
|
109
|
-
## Optimizations
|
|
110
|
-
|
|
111
|
-
Please see the main `tsdx` [optimizations docs](https://github.com/palmerhq/tsdx#optimizations). In particular, know that you can take advantage of development-only optimizations:
|
|
112
|
-
|
|
113
|
-
```js
|
|
114
|
-
// ./types/index.d.ts
|
|
115
|
-
declare var __DEV__: boolean;
|
|
116
|
-
|
|
117
|
-
// inside your code...
|
|
118
|
-
if (__DEV__) {
|
|
119
|
-
console.log('foo');
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
You can also choose to install and use [invariant](https://github.com/palmerhq/tsdx#invariant) and [warning](https://github.com/palmerhq/tsdx#warning) functions.
|
|
124
|
-
|
|
125
|
-
## Module Formats
|
|
126
|
-
|
|
127
|
-
CJS, ESModules, and UMD module formats are supported.
|
|
128
|
-
|
|
129
|
-
The appropriate paths are configured in `package.json` and `dist/index.js` accordingly. Please report if any issues are found.
|
|
130
|
-
|
|
131
|
-
## Deploying the Example Playground
|
|
132
|
-
|
|
133
|
-
The Playground is just a simple [Parcel](https://parceljs.org) app, you can deploy it anywhere you would normally deploy that. Here are some guidelines for **manually** deploying with the Netlify CLI (`npm i -g netlify-cli`):
|
|
134
|
-
|
|
135
|
-
```bash
|
|
136
|
-
cd example # if not already in the example folder
|
|
137
|
-
npm run build # builds to dist
|
|
138
|
-
netlify deploy # deploy the dist folder
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
Alternatively, if you already have a git repo connected, you can set up continuous deployment with Netlify:
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
|
-
netlify init
|
|
145
|
-
# build command: yarn build && cd example && yarn && yarn build
|
|
146
|
-
# directory to deploy: example/dist
|
|
147
|
-
# pick yes for netlify.toml
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
## Named Exports
|
|
151
|
-
|
|
152
|
-
Per Palmer Group guidelines, [always use named exports.](https://github.com/palmerhq/typescript#exports) Code split inside your React app instead of your React library.
|
|
153
|
-
|
|
154
|
-
## Including Styles
|
|
155
|
-
|
|
156
|
-
There are many ways to ship styles, including with CSS-in-JS. TSDX has no opinion on this, configure how you like.
|
|
157
|
-
|
|
158
|
-
For vanilla CSS, you can include it at the root directory and add it to the `files` section in your `package.json`, so that it can be imported separately by your users and run through their bundler's loader.
|
|
159
|
-
|
|
160
|
-
## Publishing to NPM
|
|
161
|
-
|
|
162
|
-
We recommend using [np](https://github.com/sindresorhus/np).
|
|
163
|
-
|
|
164
|
-
## Usage with Lerna
|
|
165
|
-
|
|
166
|
-
When creating a new package with TSDX within a project set up with Lerna, you might encounter a `Cannot resolve dependency` error when trying to run the `example` project. To fix that you will need to make changes to the `package.json` file _inside the `example` directory_.
|
|
167
|
-
|
|
168
|
-
The problem is that due to the nature of how dependencies are installed in Lerna projects, the aliases in the example project's `package.json` might not point to the right place, as those dependencies might have been installed in the root of your Lerna project.
|
|
169
|
-
|
|
170
|
-
Change the `alias` to point to where those packages are actually installed. This depends on the directory structure of your Lerna project, so the actual path might be different from the diff below.
|
|
171
|
-
|
|
172
|
-
```diff
|
|
173
|
-
"alias": {
|
|
174
|
-
- "react": "../node_modules/react",
|
|
175
|
-
- "react-dom": "../node_modules/react-dom"
|
|
176
|
-
+ "react": "../../../node_modules/react",
|
|
177
|
-
+ "react-dom": "../../../node_modules/react-dom"
|
|
178
|
-
},
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
An alternative to fixing this problem would be to remove aliases altogether and define the dependencies referenced as aliases as dev dependencies instead. [However, that might cause other problems.](https://github.com/palmerhq/tsdx/issues/64)
|
|
28
|
+
TODO:
|
|
29
|
+
- letter-spacing (ls)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GeneratorInterface, GeneratorConfigType } from './generator';
|
|
2
|
+
export declare class BackgroundsGenerator implements GeneratorInterface {
|
|
3
|
+
spacing: GeneratorConfigType['spacing'];
|
|
4
|
+
displays: GeneratorConfigType['displays'];
|
|
5
|
+
colors: GeneratorConfigType['colors'];
|
|
6
|
+
constructor(config: GeneratorConfigType);
|
|
7
|
+
generateHeader(): string;
|
|
8
|
+
generateCss(): string;
|
|
9
|
+
generateFooter(): string;
|
|
10
|
+
}
|
|
@@ -1023,7 +1023,12 @@ var DisplaysGenerator = /*#__PURE__*/function () {
|
|
|
1023
1023
|
var _Object$entries$_i = _Object$entries[_i],
|
|
1024
1024
|
key = _Object$entries$_i[0],
|
|
1025
1025
|
value = _Object$entries$_i[1];
|
|
1026
|
-
|
|
1026
|
+
|
|
1027
|
+
if (value === 'flex') {
|
|
1028
|
+
output += "*[data-display='" + key + "'] {\n display: " + value + ";\nflex-wrap: wrap;\n}\n";
|
|
1029
|
+
} else {
|
|
1030
|
+
output += "*[data-display='" + key + "'] {\n display: " + value + ";\n}\n";
|
|
1031
|
+
}
|
|
1027
1032
|
}
|
|
1028
1033
|
|
|
1029
1034
|
return output;
|
|
@@ -1242,6 +1247,72 @@ var FontSizeGenerator = /*#__PURE__*/function () {
|
|
|
1242
1247
|
return FontSizeGenerator;
|
|
1243
1248
|
}();
|
|
1244
1249
|
|
|
1250
|
+
var FontWeightGenerator = /*#__PURE__*/function () {
|
|
1251
|
+
function FontWeightGenerator(config) {
|
|
1252
|
+
this.spacing = config.spacing;
|
|
1253
|
+
this.displays = config.displays;
|
|
1254
|
+
this.fontWeights = config.fontWeights;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
var _proto = FontWeightGenerator.prototype;
|
|
1258
|
+
|
|
1259
|
+
_proto.generateHeader = function generateHeader() {
|
|
1260
|
+
return '/* Font sizes */\n\n';
|
|
1261
|
+
};
|
|
1262
|
+
|
|
1263
|
+
_proto.generateCss = function generateCss() {
|
|
1264
|
+
var output = ''; // Regular display: data-fw="*"
|
|
1265
|
+
|
|
1266
|
+
for (var _i = 0, _Object$entries = Object.entries(this.fontWeights); _i < _Object$entries.length; _i++) {
|
|
1267
|
+
var _Object$entries$_i = _Object$entries[_i],
|
|
1268
|
+
key = _Object$entries$_i[0],
|
|
1269
|
+
value = _Object$entries$_i[1];
|
|
1270
|
+
output += "*[data-fw='" + key + "'] {\n font-weight: " + value + ";\n}\n";
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
return output;
|
|
1274
|
+
};
|
|
1275
|
+
|
|
1276
|
+
_proto.generateFooter = function generateFooter() {
|
|
1277
|
+
return '/* ===================== */\n\n';
|
|
1278
|
+
};
|
|
1279
|
+
|
|
1280
|
+
return FontWeightGenerator;
|
|
1281
|
+
}();
|
|
1282
|
+
|
|
1283
|
+
var LineHeightsGenerator = /*#__PURE__*/function () {
|
|
1284
|
+
function LineHeightsGenerator(config) {
|
|
1285
|
+
this.spacing = config.spacing;
|
|
1286
|
+
this.displays = config.displays;
|
|
1287
|
+
this.lineHeights = config.lineHeights;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
var _proto = LineHeightsGenerator.prototype;
|
|
1291
|
+
|
|
1292
|
+
_proto.generateHeader = function generateHeader() {
|
|
1293
|
+
return '/* Line heights */\n\n';
|
|
1294
|
+
};
|
|
1295
|
+
|
|
1296
|
+
_proto.generateCss = function generateCss() {
|
|
1297
|
+
var output = ''; // Regular display: data-lh="*"
|
|
1298
|
+
|
|
1299
|
+
for (var _i = 0, _Object$entries = Object.entries(this.lineHeights); _i < _Object$entries.length; _i++) {
|
|
1300
|
+
var _Object$entries$_i = _Object$entries[_i],
|
|
1301
|
+
key = _Object$entries$_i[0],
|
|
1302
|
+
value = _Object$entries$_i[1];
|
|
1303
|
+
output += "*[data-lh='" + key + "'] {\n line-height: " + value + ";\n}\n";
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
return output;
|
|
1307
|
+
};
|
|
1308
|
+
|
|
1309
|
+
_proto.generateFooter = function generateFooter() {
|
|
1310
|
+
return '/* ===================== */\n\n';
|
|
1311
|
+
};
|
|
1312
|
+
|
|
1313
|
+
return LineHeightsGenerator;
|
|
1314
|
+
}();
|
|
1315
|
+
|
|
1245
1316
|
var FlexDirectionsGenerator = /*#__PURE__*/function () {
|
|
1246
1317
|
function FlexDirectionsGenerator(config) {
|
|
1247
1318
|
this.spacing = config.spacing;
|
|
@@ -1275,6 +1346,39 @@ var FlexDirectionsGenerator = /*#__PURE__*/function () {
|
|
|
1275
1346
|
return FlexDirectionsGenerator;
|
|
1276
1347
|
}();
|
|
1277
1348
|
|
|
1349
|
+
var BackgroundsGenerator = /*#__PURE__*/function () {
|
|
1350
|
+
function BackgroundsGenerator(config) {
|
|
1351
|
+
this.spacing = config.spacing;
|
|
1352
|
+
this.displays = config.displays;
|
|
1353
|
+
this.colors = config.colors;
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
var _proto = BackgroundsGenerator.prototype;
|
|
1357
|
+
|
|
1358
|
+
_proto.generateHeader = function generateHeader() {
|
|
1359
|
+
return '/* Backgrounds */\n\n';
|
|
1360
|
+
};
|
|
1361
|
+
|
|
1362
|
+
_proto.generateCss = function generateCss() {
|
|
1363
|
+
var output = ''; // Regular display: data-bg="*"
|
|
1364
|
+
|
|
1365
|
+
for (var _i = 0, _Object$entries = Object.entries(this.colors); _i < _Object$entries.length; _i++) {
|
|
1366
|
+
var _Object$entries$_i = _Object$entries[_i],
|
|
1367
|
+
key = _Object$entries$_i[0],
|
|
1368
|
+
value = _Object$entries$_i[1];
|
|
1369
|
+
output += "*[data-bg='" + key + "'] {\n background-color: " + value + ";\n}\n";
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
return output;
|
|
1373
|
+
};
|
|
1374
|
+
|
|
1375
|
+
_proto.generateFooter = function generateFooter() {
|
|
1376
|
+
return '/* ===================== */\n\n';
|
|
1377
|
+
};
|
|
1378
|
+
|
|
1379
|
+
return BackgroundsGenerator;
|
|
1380
|
+
}();
|
|
1381
|
+
|
|
1278
1382
|
var Spacing = {
|
|
1279
1383
|
'0': '0',
|
|
1280
1384
|
'3': '3px',
|
|
@@ -1331,12 +1435,40 @@ var FontSizes = {
|
|
|
1331
1435
|
24: '24',
|
|
1332
1436
|
32: '32'
|
|
1333
1437
|
};
|
|
1438
|
+
var FontWeights = {
|
|
1439
|
+
'300': '300',
|
|
1440
|
+
'400': '400',
|
|
1441
|
+
'500': '500',
|
|
1442
|
+
'700': '700',
|
|
1443
|
+
'900': '900',
|
|
1444
|
+
unset: 'unset'
|
|
1445
|
+
};
|
|
1446
|
+
var LineHeights = {
|
|
1447
|
+
'12': '12',
|
|
1448
|
+
'16': '16',
|
|
1449
|
+
'20': '20',
|
|
1450
|
+
'24': '24',
|
|
1451
|
+
'32': '32',
|
|
1452
|
+
unset: 'unset'
|
|
1453
|
+
};
|
|
1334
1454
|
var FlexDirections = {
|
|
1335
1455
|
row: 'row',
|
|
1336
1456
|
'row-reverse': 'row-reverse',
|
|
1337
1457
|
column: 'column',
|
|
1338
1458
|
'column-reverse': 'column-reverse'
|
|
1339
1459
|
};
|
|
1460
|
+
var Colors = {
|
|
1461
|
+
white: '#F9FAFB',
|
|
1462
|
+
'gray-100': '#F3F4F6',
|
|
1463
|
+
'gray-200': '#E5E7EB',
|
|
1464
|
+
'gray-300': '#D1D5DB',
|
|
1465
|
+
'gray-400': '#9CA3AF',
|
|
1466
|
+
'gray-500': '#6B7280',
|
|
1467
|
+
'gray-600': '#4B5563',
|
|
1468
|
+
'gray-700': '#374151',
|
|
1469
|
+
'gray-800': '#1F2937',
|
|
1470
|
+
black: '#111827'
|
|
1471
|
+
};
|
|
1340
1472
|
|
|
1341
1473
|
var GeneratorProcessor = /*#__PURE__*/function () {
|
|
1342
1474
|
function GeneratorProcessor() {}
|
|
@@ -1402,10 +1534,13 @@ function _main() {
|
|
|
1402
1534
|
zIndexes: ZIndexes,
|
|
1403
1535
|
widths: Widths,
|
|
1404
1536
|
fontSizes: FontSizes,
|
|
1405
|
-
|
|
1537
|
+
fontWeights: FontWeights,
|
|
1538
|
+
lineHeights: LineHeights,
|
|
1539
|
+
flexDirections: FlexDirections,
|
|
1540
|
+
colors: Colors
|
|
1406
1541
|
};
|
|
1407
1542
|
_context2.next = 3;
|
|
1408
|
-
return new GeneratorProcessor().process([new Margins(config), new Paddings(config), new DisplaysGenerator(config), new AxisPlacementsGenerator(config), new
|
|
1543
|
+
return new GeneratorProcessor().process([new Margins(config), new Paddings(config), new DisplaysGenerator(config), new AxisPlacementsGenerator(config), new FlexWrapGenerator(config), new FlexDirectionsGenerator(config), new WidthsGenerator(config), new PositionsGenerator(config), new ZIndexGenerator(config), new FontSizeGenerator(config), new FontWeightGenerator(config), new LineHeightsGenerator(config), new BackgroundsGenerator(config)]);
|
|
1409
1544
|
|
|
1410
1545
|
case 3:
|
|
1411
1546
|
case "end":
|