@flodesk/grain 1.4.0 → 1.6.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 +23 -22
- package/es/base-styles.css +17 -6
- package/es/components/text/index.js +4 -4
- package/es/utilities/index.js +14 -8
- package/es/variables/index.js +9 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,34 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
# Grain design system
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Installation
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm run dev
|
|
9
|
-
# or
|
|
10
|
-
yarn dev
|
|
5
|
+
```
|
|
6
|
+
npm install @flodesk/grain
|
|
11
7
|
```
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.
|
|
16
|
-
|
|
17
|
-
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.
|
|
9
|
+
### Add base styles
|
|
18
10
|
|
|
19
|
-
|
|
11
|
+
`base-styles.css` contains all Grain global styles. Import it in the highest component possible so that it's accessible everywhere in the UI.
|
|
20
12
|
|
|
21
|
-
|
|
13
|
+
```js
|
|
14
|
+
import "@flodesk/grain/es/base-styles.css";
|
|
15
|
+
```
|
|
22
16
|
|
|
23
|
-
|
|
17
|
+
## Usage
|
|
24
18
|
|
|
25
|
-
|
|
26
|
-
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
|
19
|
+
### Component usage
|
|
27
20
|
|
|
28
|
-
|
|
21
|
+
```jsx
|
|
22
|
+
import { Text, Button, Input } from "@flodesk/grain";
|
|
29
23
|
|
|
30
|
-
|
|
24
|
+
<Text>Content</Text>;
|
|
25
|
+
```
|
|
31
26
|
|
|
32
|
-
|
|
27
|
+
### CSS variable usage
|
|
33
28
|
|
|
34
|
-
|
|
29
|
+
```css
|
|
30
|
+
.dashboard-header {
|
|
31
|
+
font-size: var(--grn-text-xl);
|
|
32
|
+
margin-bottom: var(--grn-space-l);
|
|
33
|
+
color: var(--grn-color-bodyDimmed);
|
|
34
|
+
}
|
|
35
|
+
```
|
package/es/base-styles.css
CHANGED
|
@@ -26,11 +26,9 @@
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
:root {
|
|
29
|
-
--
|
|
30
|
-
|
|
31
|
-
--grn-color-
|
|
32
|
-
|
|
33
|
-
--grn-color-grey8: hsl(0 0% 7%);
|
|
29
|
+
--grey8-HSL: 0 0% 7%;
|
|
30
|
+
|
|
31
|
+
--grn-color-grey8: hsl(var(--grey8-HSL));
|
|
34
32
|
--grn-color-grey7: hsl(0 0% 20%);
|
|
35
33
|
--grn-color-grey6: hsl(0 0% 32%);
|
|
36
34
|
--grn-color-grey5: hsl(0 0% 44%);
|
|
@@ -38,6 +36,19 @@
|
|
|
38
36
|
--grn-color-grey3: hsl(0 0% 78%);
|
|
39
37
|
--grn-color-grey2: hsl(0 0% 87%);
|
|
40
38
|
--grn-color-grey1: hsl(0 0% 96%);
|
|
39
|
+
|
|
40
|
+
--grn-color-blue: hsl(218 74% 54%);
|
|
41
|
+
--grn-color-red: hsl(6 66% 65%);
|
|
42
|
+
|
|
43
|
+
--grn-color-body: var(--grn-color-grey8);
|
|
44
|
+
--grn-color-bodyDimmed: hsl(var(--grey8-HSL) / 50%);
|
|
45
|
+
--grn-color-accent: var(--grn-color-grey8);
|
|
46
|
+
--grn-color-backgroundSecondary: hsl(0 0% 100%);
|
|
47
|
+
--grn-color-background: var(--grn-color-grey1);
|
|
48
|
+
--grn-color-overlay: hsl(var(--grey8-HSL) / 7%);
|
|
49
|
+
--grn-color-border: hsl(var(--grey8-HSL) / 9%);
|
|
50
|
+
--grn-color-selection: var(--grn-color-blue);
|
|
51
|
+
--grn-color-danger: var(--grn-color-red);
|
|
41
52
|
}
|
|
42
53
|
|
|
43
54
|
* {
|
|
@@ -52,7 +63,7 @@
|
|
|
52
63
|
}
|
|
53
64
|
|
|
54
65
|
body {
|
|
55
|
-
font-family: 'BeausiteClassic';
|
|
66
|
+
font-family: 'BeausiteClassic', sans-serif;
|
|
56
67
|
color: var(--grn-color-body);
|
|
57
68
|
font-size: var(--grn-text-m);
|
|
58
69
|
}
|
|
@@ -7,9 +7,9 @@ var _templateObject;
|
|
|
7
7
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
8
8
|
|
|
9
9
|
import { getColor, getTextSize, getWeight } from '../../utilities';
|
|
10
|
-
import { textSizes, weights } from '../../variables';
|
|
11
10
|
import PropTypes from 'prop-types';
|
|
12
11
|
import React from "react";
|
|
12
|
+
import { cssVarOptions } from '../../variables';
|
|
13
13
|
import styled from "@emotion/styled";
|
|
14
14
|
var Wrapper = styled.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: block;\n font-size: ", ";\n font-weight: ", ";\n color: ", ";\n"])), function (p) {
|
|
15
15
|
return getTextSize(p.size);
|
|
@@ -32,7 +32,7 @@ export var Text = function Text(_ref) {
|
|
|
32
32
|
}, children);
|
|
33
33
|
};
|
|
34
34
|
Text.propTypes = {
|
|
35
|
-
size: PropTypes.oneOf(textSizes),
|
|
36
|
-
weight: PropTypes.oneOf(weights),
|
|
37
|
-
color: PropTypes.oneOfType([PropTypes.oneOf(weights), PropTypes.string])
|
|
35
|
+
size: PropTypes.oneOf(cssVarOptions.textSizes),
|
|
36
|
+
weight: PropTypes.oneOf(cssVarOptions.weights),
|
|
37
|
+
color: PropTypes.oneOfType([PropTypes.oneOf(cssVarOptions.weights), PropTypes.string])
|
|
38
38
|
};
|
package/es/utilities/index.js
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
|
+
import "core-js/modules/es.array.concat.js";
|
|
1
2
|
import "core-js/modules/es.array.includes.js";
|
|
2
3
|
import "core-js/modules/es.string.includes.js";
|
|
3
|
-
import "
|
|
4
|
-
|
|
4
|
+
import { cssVarOptions, grnPrefix } from "../variables";
|
|
5
|
+
export var getCssVarCore = function getCssVarCore(type, value) {
|
|
6
|
+
return "".concat(grnPrefix).concat(type, "-").concat(value);
|
|
7
|
+
};
|
|
8
|
+
export var getCssVar = function getCssVar(type, value) {
|
|
9
|
+
return "var(".concat(getCssVarCore(type, value), ")");
|
|
10
|
+
};
|
|
5
11
|
export var getColor = function getColor(color) {
|
|
6
|
-
if (
|
|
7
|
-
return
|
|
12
|
+
if (cssVarOptions.colors.includes(color)) {
|
|
13
|
+
return getCssVar("color", color);
|
|
8
14
|
}
|
|
9
15
|
|
|
10
16
|
return color;
|
|
11
17
|
};
|
|
12
18
|
export var getTextSize = function getTextSize(size) {
|
|
13
|
-
if (textSizes.includes(size)) {
|
|
14
|
-
return
|
|
19
|
+
if (cssVarOptions.textSizes.includes(size)) {
|
|
20
|
+
return getCssVar("text", size);
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
return size;
|
|
18
24
|
};
|
|
19
25
|
export var getWeight = function getWeight(weight) {
|
|
20
|
-
if (weights.includes(weight)) {
|
|
21
|
-
return
|
|
26
|
+
if (cssVarOptions.weights.includes(weight)) {
|
|
27
|
+
return getCssVar("weight", weight);
|
|
22
28
|
}
|
|
23
29
|
};
|
package/es/variables/index.js
CHANGED
|
@@ -29,14 +29,13 @@ for (var step = 1; step < greysAmount + 1; step++) {
|
|
|
29
29
|
greysArray.push("grey" + step);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export var
|
|
33
|
-
export var spaceVarPrefix = "space-";
|
|
34
|
-
export var weightVarPrefix = "weight-";
|
|
35
|
-
export var textVarPrefix = "text-";
|
|
36
|
-
export var colorVarPrefix = "color-";
|
|
32
|
+
export var grnPrefix = "--grn-";
|
|
37
33
|
export var greys = greysArray.reverse();
|
|
38
|
-
export var semanticColors = ["body", "bodyDimmed", "
|
|
39
|
-
export var
|
|
40
|
-
export var
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
export var semanticColors = ["body", "bodyDimmed", "accent", "backgroundSecondary", "background", "overlay", "border", "selection", "danger"];
|
|
35
|
+
export var baseColors = ["blue", "red"];
|
|
36
|
+
export var cssVarOptions = {
|
|
37
|
+
textSizes: ["s", "m", "l", "xl", "xxl"],
|
|
38
|
+
spaces: ["xs", "s", "m", "l", "xl", "xxl"],
|
|
39
|
+
weights: ["normal", "medium", "semiBold"],
|
|
40
|
+
colors: [].concat(_toConsumableArray(greys), baseColors, semanticColors)
|
|
41
|
+
};
|