@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 CHANGED
@@ -1,34 +1,35 @@
1
- This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
1
+ # Grain design system
2
2
 
3
- ## Getting Started
3
+ ## Installation
4
4
 
5
- First, run the development server:
6
-
7
- ```bash
8
- npm run dev
9
- # or
10
- yarn dev
5
+ ```
6
+ npm install @flodesk/grain
11
7
  ```
12
8
 
13
- Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
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
- The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
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
- ## Learn More
13
+ ```js
14
+ import "@flodesk/grain/es/base-styles.css";
15
+ ```
22
16
 
23
- To learn more about Next.js, take a look at the following resources:
17
+ ## Usage
24
18
 
25
- - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
26
- - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
19
+ ### Component usage
27
20
 
28
- You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
21
+ ```jsx
22
+ import { Text, Button, Input } from "@flodesk/grain";
29
23
 
30
- ## Deploy on Vercel
24
+ <Text>Content</Text>;
25
+ ```
31
26
 
32
- The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
27
+ ### CSS variable usage
33
28
 
34
- Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
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
+ ```
@@ -26,11 +26,9 @@
26
26
  }
27
27
 
28
28
  :root {
29
- --grn-color-body: hsl(0 0% 7%);
30
- --grn-color-bodyDimmed: hsl(0 0% 7% / 50%);
31
- --grn-color-primary: hsl(0 0% 7%);
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
  };
@@ -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 "core-js/modules/es.array.concat.js";
4
- import { allColors, colorVarPrefix, cssVarPrefix, textSizes, textVarPrefix, weightVarPrefix, weights } from "../variables";
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 (allColors.includes(color)) {
7
- return "var(".concat(cssVarPrefix).concat(colorVarPrefix).concat(color, ")");
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 "var(".concat(cssVarPrefix).concat(textVarPrefix).concat(size, ")");
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 "var(".concat(cssVarPrefix).concat(weightVarPrefix).concat(weight, ")");
26
+ if (cssVarOptions.weights.includes(weight)) {
27
+ return getCssVar("weight", weight);
22
28
  }
23
29
  };
@@ -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 cssVarPrefix = "--grn-";
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", "primary"];
39
- export var textSizes = ["s", "m", "l", "xl", "xxl"];
40
- export var spaces = ["xs", "s", "m", "l", "xl", "xxl"];
41
- export var weights = ["normal", "medium", "semiBold"];
42
- export var allColors = [].concat(_toConsumableArray(greys), semanticColors);
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flodesk/grain",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "Flodesk design system",
5
5
  "module": "es/index.js",
6
6
  "author": "Flodesk",