@flodesk/grain 2.4.6 → 2.5.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 +14 -0
- package/es/components/button/index.js +43 -0
- package/es/components/index.js +3 -1
- package/es/components/input/index.js +45 -0
- package/es/styles/base.css +3 -2
- package/es/styles/components-variables.css +9 -0
- package/es/styles/variables.css +2 -3
- package/es/variables/index.js +0 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,6 +14,20 @@ npm install @flodesk/grain
|
|
|
14
14
|
import "@flodesk/grain/es/styles/base.css";
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
### Add text styles context
|
|
18
|
+
|
|
19
|
+
Add `grn-context` class to a parent wrapper, this class sets dynamically the `line-height` and the `letter-spacing`. It can be added to a smaller UI section or to the page wrapper. Set it on as many wrappers as needed.
|
|
20
|
+
|
|
21
|
+
In the future, once Grain is widely adopted, we will remove these classes and apply the text styles globally.
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
<div className="some-wrapper grn-context">
|
|
25
|
+
<Text size="l">Content</Text>
|
|
26
|
+
// or
|
|
27
|
+
<div className="element-with-grain-styles">Content</div>
|
|
28
|
+
</div>
|
|
29
|
+
```
|
|
30
|
+
|
|
17
31
|
## Usage
|
|
18
32
|
|
|
19
33
|
### Component usage
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import "core-js/modules/es.array.slice.js";
|
|
2
|
+
import "core-js/modules/es.object.freeze.js";
|
|
3
|
+
import "core-js/modules/es.object.define-properties.js";
|
|
4
|
+
import "core-js/modules/es.object.keys.js";
|
|
5
|
+
import "core-js/modules/es.array.index-of.js";
|
|
6
|
+
import "core-js/modules/es.symbol.js";
|
|
7
|
+
var _excluded = ["children", "size", "weight", "color", "tag"];
|
|
8
|
+
|
|
9
|
+
var _templateObject, _templateObject2;
|
|
10
|
+
|
|
11
|
+
import "core-js/modules/es.object.assign.js";
|
|
12
|
+
|
|
13
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
14
|
+
|
|
15
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
16
|
+
|
|
17
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
18
|
+
|
|
19
|
+
import { getColor, getRadius, getSpace, getTextSize, getWeight } from '../../utilities';
|
|
20
|
+
import { PropTypes } from 'prop-types';
|
|
21
|
+
import React from "react";
|
|
22
|
+
import styled from "@emotion/styled";
|
|
23
|
+
import { types } from '../../types';
|
|
24
|
+
var Wrapper = styled.button(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n appearance: none;\n border: none;\n font-family: inherit;\n font-size: ", ";\n font-weight: ", ";\n cursor: pointer;\n background-color: ", ";\n color: ", ";\n border-radius: 0.34em;\n height: var(--grn-textBoxHeight);\n padding: 0 var(--grn-buttonTextBoxPaddingX);\n"])), getTextSize('m'), getWeight('medium'), getColor('body'), getColor('white'));
|
|
25
|
+
var ButtonText = styled.span(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n top: -0.3px;\n"])));
|
|
26
|
+
export var Button = function Button(_ref) {
|
|
27
|
+
var children = _ref.children,
|
|
28
|
+
_ref$size = _ref.size,
|
|
29
|
+
size = _ref$size === void 0 ? 'm' : _ref$size,
|
|
30
|
+
_ref$weight = _ref.weight,
|
|
31
|
+
weight = _ref$weight === void 0 ? 'normal' : _ref$weight,
|
|
32
|
+
color = _ref.color,
|
|
33
|
+
tag = _ref.tag,
|
|
34
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
35
|
+
|
|
36
|
+
return /*#__PURE__*/React.createElement(Wrapper, Object.assign({
|
|
37
|
+
size: size,
|
|
38
|
+
weight: weight,
|
|
39
|
+
color: color,
|
|
40
|
+
as: tag
|
|
41
|
+
}, props), /*#__PURE__*/React.createElement(ButtonText, null, children));
|
|
42
|
+
};
|
|
43
|
+
Button.propTypes = {};
|
package/es/components/index.js
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import "core-js/modules/es.array.slice.js";
|
|
2
|
+
import "core-js/modules/es.object.freeze.js";
|
|
3
|
+
import "core-js/modules/es.object.define-properties.js";
|
|
4
|
+
import "core-js/modules/es.object.keys.js";
|
|
5
|
+
import "core-js/modules/es.array.index-of.js";
|
|
6
|
+
import "core-js/modules/es.symbol.js";
|
|
7
|
+
var _excluded = ["value", "placeholder", "size"];
|
|
8
|
+
|
|
9
|
+
var _templateObject;
|
|
10
|
+
|
|
11
|
+
import "core-js/modules/es.object.assign.js";
|
|
12
|
+
|
|
13
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
14
|
+
|
|
15
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
16
|
+
|
|
17
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
18
|
+
|
|
19
|
+
import { getColor, getRadius, getSpace, getTextSize, getWeight } from '../../utilities';
|
|
20
|
+
import { PropTypes } from 'prop-types';
|
|
21
|
+
import React from "react";
|
|
22
|
+
import styled from "@emotion/styled";
|
|
23
|
+
import { types } from '../../types';
|
|
24
|
+
var Wrapper = styled.input(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n appearance: none;\n border: none;\n font-family: inherit;\n background-color: transparent;\n color: inherit;\n font-size: ", ";\n border-radius: ", ";\n border: 1px solid ", ";\n height: ", ";\n padding: 0 ", ";\n width: 100%;\n"])), function (p) {
|
|
25
|
+
return getTextSize(p.size);
|
|
26
|
+
}, getRadius('m'), getColor('grey3'), function (p) {
|
|
27
|
+
return "var(--grn-textBoxHeight-".concat(p.size, ")");
|
|
28
|
+
}, function (p) {
|
|
29
|
+
return "var(--grn-fieldTextBoxPaddingX-".concat(p.size, ")");
|
|
30
|
+
});
|
|
31
|
+
export var Input = function Input(_ref) {
|
|
32
|
+
var value = _ref.value,
|
|
33
|
+
_ref$placeholder = _ref.placeholder,
|
|
34
|
+
placeholder = _ref$placeholder === void 0 ? 'Placeholder' : _ref$placeholder,
|
|
35
|
+
_ref$size = _ref.size,
|
|
36
|
+
size = _ref$size === void 0 ? 'm' : _ref$size,
|
|
37
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
38
|
+
|
|
39
|
+
return /*#__PURE__*/React.createElement(Wrapper, Object.assign({
|
|
40
|
+
value: value,
|
|
41
|
+
placeholder: placeholder,
|
|
42
|
+
size: size
|
|
43
|
+
}, props));
|
|
44
|
+
};
|
|
45
|
+
Input.propTypes = {};
|
package/es/styles/base.css
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
@import './variables.css';
|
|
2
|
+
@import './components-variables.css';
|
|
2
3
|
|
|
3
4
|
:root {
|
|
4
5
|
--grn-letterSpacing-fixed: 1.3px;
|
|
5
6
|
--grn-letterSpacing-relative: 0.07em;
|
|
6
7
|
--grn-letterSpacing-global: calc(var(--grn-letterSpacing-fixed) - var(--grn-letterSpacing-relative));
|
|
7
8
|
|
|
8
|
-
--grn-lineHeight-fixed:
|
|
9
|
+
--grn-lineHeight-fixed: 7px;
|
|
9
10
|
--grn-lineHeight-relative: 0.9em;
|
|
10
11
|
--grn-lineHeight-global: calc(var(--grn-lineHeight-fixed) + var(--grn-lineHeight-relative));
|
|
11
12
|
|
|
12
13
|
--grn-font-global: 'Beausite Classic', sans-serif;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
* {
|
|
16
|
+
.grn-context, .grn-context * {
|
|
16
17
|
letter-spacing: var(--grn-letterSpacing-global);
|
|
17
18
|
line-height: var(--grn-lineHeight-global);
|
|
18
19
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--grn-textBoxHeight-s: calc(var(--grn-unit) * 3.5);
|
|
3
|
+
--grn-textBoxHeight-m: calc(var(--grn-unit) * 5);
|
|
4
|
+
|
|
5
|
+
--grn-buttonTextBoxPaddingX: calc(var(--grn-textBoxHeight) / 2);
|
|
6
|
+
|
|
7
|
+
--grn-fieldTextBoxPaddingX-s: calc(var(--grn-unit) * 1);
|
|
8
|
+
--grn-fieldTextBoxPaddingX-m: calc(var(--grn-unit) * 1.5);
|
|
9
|
+
}
|
package/es/styles/variables.css
CHANGED
|
@@ -26,8 +26,7 @@
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
:root {
|
|
29
|
-
--grn-radius-
|
|
30
|
-
--grn-radius-m: calc(var(--grn-unit) * 1);
|
|
29
|
+
--grn-radius-m: calc(var(--grn-unit) * 0.625);
|
|
31
30
|
--grn-radius-l: calc(var(--grn-unit) * 1.25);
|
|
32
31
|
--grn-radius-xl: calc(var(--grn-unit) * 2);
|
|
33
32
|
}
|
|
@@ -78,4 +77,4 @@
|
|
|
78
77
|
var(--grn-shadowLayer-1),
|
|
79
78
|
var(--grn-shadowLayer-4)
|
|
80
79
|
;
|
|
81
|
-
}
|
|
80
|
+
}
|
package/es/variables/index.js
CHANGED