@doodl/slate 1.21.4 → 1.22.2
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/CHANGELOG.md +26 -0
- package/js/dist/accordion/accordion.js +2 -0
- package/js/dist/react-components/container/index.js +24 -0
- package/js/dist/react-components/grid/grid-item.js +35 -0
- package/js/dist/react-components/grid/index.js +43 -0
- package/js/dist/react-components/grid/padded-grid.js +27 -0
- package/js/dist/react-components/section/index.js +28 -0
- package/js/dist/react-components/typography/index.js +39 -0
- package/package.json +7 -1
- package/scss/_helpers.scss +208 -0
- package/scss/_mixins.scss +197 -65
- package/scss/core/_base.scss +4 -3
- package/scss/core/_button.scss +34 -16
- package/scss/core/_layout.scss +5 -56
- package/scss/core/_lists.scss +1 -13
- package/scss/core/_typography.scss +2 -14
- package/scss/core/global-helpers/_button.scss +11 -0
- package/scss/core/parts/_container-safe.scss +20 -0
- package/scss/core/parts/_grid-safe.scss +147 -0
- package/scss/core/parts/_gutter-safe.scss +16 -0
- package/scss/core/parts/_lists-safe.scss +15 -0
- package/scss/core/parts/_section-safe.scss +27 -0
- package/scss/core/parts/_typography-safe.scss +34 -0
- package/scss/css-modules/container.module.scss +2 -0
- package/scss/css-modules/grid.module.scss +13 -0
- package/scss/css-modules/section.module.scss +2 -0
- package/scss/css-modules/typography.module.scss +11 -0
- package/scss/css-modules/utils.module.scss +3 -0
- package/scss/globalcustoms.scss +1 -0
- package/scss/silverstripe/_messages.scss +15 -10
- package/scss/variables/_base.scss +3 -2
- package/scss/variables/_button.scss +9 -8
- package/scss/variables/_colours.scss +21 -1
- package/scss/variables/_forms.scss +1 -1
- package/scss/variables/_menu-bar.scss +2 -1
- package/scss/variables/_silverstripe-messages.scss +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.22.2](https://bitbucket.org/doodlltd/slate/compare/v1.22.1...v1.22.2) (2021-12-22)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* Assign property inheritance to variable properties if the value is a property map ([71a9287](https://bitbucket.org/doodlltd/slate/commit/71a9287b2846bbccb4ffd19e185d26542dbdca3c))
|
|
11
|
+
* Ensure $key is not required to assign a variable property ([02c419f](https://bitbucket.org/doodlltd/slate/commit/02c419f0ce5c58fc329b13c1520c23813179d7d4))
|
|
12
|
+
* Nested map-get doesn't work on older Sass compilers ([1b9c98b](https://bitbucket.org/doodlltd/slate/commit/1b9c98be844a6bc096aa7d9a1f9c4560d0ebd3ec))
|
|
13
|
+
|
|
14
|
+
### [1.22.1](https://bitbucket.org/doodlltd/slate/compare/v1.22.0...v1.22.1) (2021-12-22)
|
|
15
|
+
|
|
16
|
+
## [1.22.0](https://bitbucket.org/doodlltd/slate/compare/v1.21.5...v1.22.0) (2021-12-16)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
* Add basic style customisation through custom CSS properties ([d549499](https://bitbucket.org/doodlltd/slate/commit/d5494998c7afc634a217dca874ab02b17f31eafc))
|
|
22
|
+
* Add react components with modular styles ([0b5a5eb](https://bitbucket.org/doodlltd/slate/commit/0b5a5eb3f90079bce7c30005881162261dff05eb))
|
|
23
|
+
|
|
24
|
+
### [1.21.5](https://bitbucket.org/doodlltd/slate/compare/v1.21.4...v1.21.5) (2021-09-01)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Bug Fixes
|
|
28
|
+
|
|
29
|
+
* Resolve missing accessible name from accordion toggle button ([71d22fa](https://bitbucket.org/doodlltd/slate/commit/71d22fa87461efd1d506e11b3c3610ea7fa57b20))
|
|
30
|
+
|
|
5
31
|
### [1.21.4](https://bitbucket.org/doodlltd/slate/compare/v1.21.3...v1.21.4) (2021-09-01)
|
|
6
32
|
|
|
7
33
|
### [1.21.3](https://bitbucket.org/doodlltd/slate/compare/v1.21.2...v1.21.3) (2021-08-19)
|
|
@@ -115,6 +115,8 @@ var AccordionRow = /*#__PURE__*/function () {
|
|
|
115
115
|
_classPrivateFieldGet(_this, _toggleElement).className = _classPrivateFieldGet(_this, _options).toggleBtnClass;
|
|
116
116
|
_classPrivateFieldGet(_this, _toggleElement).innerHTML = _classPrivateFieldGet(_this, _options).toggleHTML;
|
|
117
117
|
|
|
118
|
+
_classPrivateFieldGet(_this, _toggleElement).setAttribute("aria-label", "Expand Menu");
|
|
119
|
+
|
|
118
120
|
_classPrivateFieldGet(_this, _toggleElement).addEventListener("click", _this.toggleRow);
|
|
119
121
|
|
|
120
122
|
_this.element.parentNode.appendChild(_classPrivateFieldGet(_this, _toggleElement));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import styles from '../../../../scss/css-modules/container.module.scss';
|
|
6
|
+
|
|
7
|
+
var Container = function Container(props) {
|
|
8
|
+
var _classNames;
|
|
9
|
+
|
|
10
|
+
var children = props.children,
|
|
11
|
+
_props$center = props.center,
|
|
12
|
+
center = _props$center === void 0 ? false : _props$center,
|
|
13
|
+
_props$horizontalPadd = props.horizontalPadding,
|
|
14
|
+
horizontalPadding = _props$horizontalPadd === void 0 ? false : _props$horizontalPadd,
|
|
15
|
+
_props$wide = props.wide,
|
|
16
|
+
wide = _props$wide === void 0 ? false : _props$wide,
|
|
17
|
+
className = props.className;
|
|
18
|
+
var containerClass = classNames(styles['container'], (_classNames = {}, _defineProperty(_classNames, styles['center'], center), _defineProperty(_classNames, styles['horizontal-padding'], horizontalPadding), _defineProperty(_classNames, styles['wide'], wide), _classNames), className);
|
|
19
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
20
|
+
className: containerClass
|
|
21
|
+
}, children);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default Container;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
+
|
|
7
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
|
+
|
|
9
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
+
|
|
11
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
12
|
+
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import classNames from "classnames";
|
|
15
|
+
import styles from '../../../../scss/css-modules/grid.module.scss';
|
|
16
|
+
|
|
17
|
+
var GridItem = function GridItem(props) {
|
|
18
|
+
var children = props.children,
|
|
19
|
+
className = props.className,
|
|
20
|
+
_props$component = props.component,
|
|
21
|
+
Component = _props$component === void 0 ? 'div' : _props$component,
|
|
22
|
+
_props$sizes = props.sizes,
|
|
23
|
+
sizes = _props$sizes === void 0 ? "" : _props$sizes;
|
|
24
|
+
var slateGridClassName = styles.slateGridClassName; // Extract dynamic grid item width classname from styles
|
|
25
|
+
|
|
26
|
+
var gridSizes = sizes.split(" ").map(function (size) {
|
|
27
|
+
return styles["".concat(slateGridClassName, "--item-width-").concat(size)];
|
|
28
|
+
});
|
|
29
|
+
var gridItemClasses = classNames.apply(void 0, _toConsumableArray(gridSizes).concat([className]));
|
|
30
|
+
return /*#__PURE__*/React.createElement(Component, {
|
|
31
|
+
className: gridItemClasses
|
|
32
|
+
}, children);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default GridItem;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
+
|
|
5
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
+
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
|
|
9
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
10
|
+
|
|
11
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
|
+
|
|
13
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
14
|
+
|
|
15
|
+
import React from 'react';
|
|
16
|
+
import classNames from 'classnames';
|
|
17
|
+
import styles from '../../../../scss/css-modules/grid.module.scss';
|
|
18
|
+
|
|
19
|
+
var Grid = function Grid(props) {
|
|
20
|
+
var _ref;
|
|
21
|
+
|
|
22
|
+
var children = props.children,
|
|
23
|
+
_props$component = props.component,
|
|
24
|
+
Component = _props$component === void 0 ? 'div' : _props$component,
|
|
25
|
+
_props$center = props.center,
|
|
26
|
+
center = _props$center === void 0 ? false : _props$center,
|
|
27
|
+
gridClassName = props.gridClassName,
|
|
28
|
+
_props$sizes = props.sizes,
|
|
29
|
+
sizes = _props$sizes === void 0 ? "" : _props$sizes,
|
|
30
|
+
_props$verticalCenter = props.verticalCenter,
|
|
31
|
+
verticalCenter = _props$verticalCenter === void 0 ? false : _props$verticalCenter;
|
|
32
|
+
var slateGridClassName = styles.slateGridClassName; // Extract dynamic grid width classname from styles
|
|
33
|
+
|
|
34
|
+
var gridSizes = sizes.split(" ").map(function (size) {
|
|
35
|
+
return styles["".concat(slateGridClassName, "-width-").concat(size)];
|
|
36
|
+
});
|
|
37
|
+
var gridClasses = classNames.apply(void 0, [styles[slateGridClassName]].concat(_toConsumableArray(gridSizes), [(_ref = {}, _defineProperty(_ref, styles['center'], center), _defineProperty(_ref, styles['verticalCenter'], verticalCenter), _ref), gridClassName]));
|
|
38
|
+
return /*#__PURE__*/React.createElement(Component, {
|
|
39
|
+
className: gridClasses
|
|
40
|
+
}, children);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default Grid;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var _excluded = ["children", "component", "className", "gridClassName"];
|
|
2
|
+
|
|
3
|
+
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; }
|
|
4
|
+
|
|
5
|
+
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; }
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import classNames from "classnames";
|
|
9
|
+
import Grid from ".";
|
|
10
|
+
import styles from '../../../../scss/css-modules/grid.module.scss';
|
|
11
|
+
|
|
12
|
+
var PaddedGrid = function PaddedGrid(props) {
|
|
13
|
+
var children = props.children,
|
|
14
|
+
_props$component = props.component,
|
|
15
|
+
Component = _props$component === void 0 ? 'div' : _props$component,
|
|
16
|
+
className = props.className,
|
|
17
|
+
gridClassName = props.gridClassName,
|
|
18
|
+
gridProps = _objectWithoutProperties(props, _excluded);
|
|
19
|
+
|
|
20
|
+
var slatePaddedGridClassName = styles.slatePaddedGridClassName;
|
|
21
|
+
var paddedGridClasses = classNames(styles[slatePaddedGridClassName], className);
|
|
22
|
+
return /*#__PURE__*/React.createElement(Component, {
|
|
23
|
+
className: paddedGridClasses
|
|
24
|
+
}, /*#__PURE__*/React.createElement(Grid, gridProps, children));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default PaddedGrid;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import styles from '../../../../scss/css-modules/section.module.scss';
|
|
6
|
+
|
|
7
|
+
var Section = function Section(props) {
|
|
8
|
+
var _classNames;
|
|
9
|
+
|
|
10
|
+
var children = props.children,
|
|
11
|
+
_props$component = props.component,
|
|
12
|
+
Component = _props$component === void 0 ? 'section' : _props$component,
|
|
13
|
+
className = props.className,
|
|
14
|
+
_props$removeBottomPa = props.removeBottomPadding,
|
|
15
|
+
removeBottomPadding = _props$removeBottomPa === void 0 ? false : _props$removeBottomPa,
|
|
16
|
+
_props$removeTopPaddi = props.removeTopPadding,
|
|
17
|
+
removeTopPadding = _props$removeTopPaddi === void 0 ? false : _props$removeTopPaddi,
|
|
18
|
+
_props$removeLeftPadd = props.removeLeftPadding,
|
|
19
|
+
removeLeftPadding = _props$removeLeftPadd === void 0 ? false : _props$removeLeftPadd,
|
|
20
|
+
_props$removeRightPad = props.removeRightPadding,
|
|
21
|
+
removeRightPadding = _props$removeRightPad === void 0 ? false : _props$removeRightPad;
|
|
22
|
+
var classes = classNames(styles.section, (_classNames = {}, _defineProperty(_classNames, styles['remove-bottom-padding'], removeBottomPadding), _defineProperty(_classNames, styles['remove-top-padding'], removeTopPadding), _defineProperty(_classNames, styles['remove-left-padding'], removeLeftPadding), _defineProperty(_classNames, styles['remove-right-padding'], removeRightPadding), _classNames), className);
|
|
23
|
+
return /*#__PURE__*/React.createElement(Component, {
|
|
24
|
+
className: classes
|
|
25
|
+
}, children);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default Section;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var _excluded = ["align", "children", "component", "wide", "fullWidth", "removeHorizontalPadding", "removeVerticalPadding"];
|
|
2
|
+
|
|
3
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
|
|
7
|
+
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; }
|
|
8
|
+
|
|
9
|
+
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; }
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import classNames from 'classnames';
|
|
13
|
+
import styles from '../../../../scss/css-modules/typography.module.scss';
|
|
14
|
+
|
|
15
|
+
var Typography = function Typography(props) {
|
|
16
|
+
var _classNames;
|
|
17
|
+
|
|
18
|
+
var _props$align = props.align,
|
|
19
|
+
align = _props$align === void 0 ? "center" : _props$align,
|
|
20
|
+
children = props.children,
|
|
21
|
+
_props$component = props.component,
|
|
22
|
+
Component = _props$component === void 0 ? 'div' : _props$component,
|
|
23
|
+
_props$wide = props.wide,
|
|
24
|
+
wide = _props$wide === void 0 ? false : _props$wide,
|
|
25
|
+
_props$fullWidth = props.fullWidth,
|
|
26
|
+
fullWidth = _props$fullWidth === void 0 ? false : _props$fullWidth,
|
|
27
|
+
_props$removeHorizont = props.removeHorizontalPadding,
|
|
28
|
+
removeHorizontalPadding = _props$removeHorizont === void 0 ? false : _props$removeHorizont,
|
|
29
|
+
_props$removeVertical = props.removeVerticalPadding,
|
|
30
|
+
removeVerticalPadding = _props$removeVertical === void 0 ? false : _props$removeVertical,
|
|
31
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
32
|
+
|
|
33
|
+
var typographyClasses = classNames(styles.typography, (_classNames = {}, _defineProperty(_classNames, styles['align-left'], align === "left"), _defineProperty(_classNames, styles['align-right'], align === "right"), _defineProperty(_classNames, styles.wide, wide), _defineProperty(_classNames, styles['full-width'], fullWidth), _defineProperty(_classNames, styles['remove-horizontal-padding'], removeHorizontalPadding), _defineProperty(_classNames, styles['remove-vertical-padding'], removeVerticalPadding), _classNames));
|
|
34
|
+
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
35
|
+
className: typographyClasses
|
|
36
|
+
}, rest), children);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default Typography;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doodl/slate",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./js/dist/index.js",
|
|
6
6
|
"module": "./js/dist/index.js",
|
|
@@ -28,14 +28,20 @@
|
|
|
28
28
|
"homepage": "https://bitbucket.org/doodlltd/slate#readme",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@babel/cli": "^7.10.4",
|
|
31
|
+
"@babel/preset-react": "^7.16.5",
|
|
31
32
|
"@doodl/common-js-config": "^1.7.0",
|
|
32
33
|
"@doodl/eslint-config": "npm:@doodl/common-js-config@^1.7.0",
|
|
33
34
|
"standard-version": "^9.1.1"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
37
|
+
"classnames": "^2.3.1",
|
|
36
38
|
"core-js": "^3.6.5",
|
|
37
39
|
"domready": "^1.0.8",
|
|
38
40
|
"gsap": "^3.4.2",
|
|
39
41
|
"lodash": "^4.17.19"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"react": ">=16.13.1 <=18",
|
|
45
|
+
"react-dom": ">=16.13.1 <=18"
|
|
40
46
|
}
|
|
41
47
|
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
@function _hex-to-dec($string) {
|
|
2
|
+
$hex: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f";
|
|
3
|
+
$string: to-lower-case($string);
|
|
4
|
+
|
|
5
|
+
@if $string == "" {
|
|
6
|
+
$string: "ff";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
$length: str-length($string);
|
|
10
|
+
|
|
11
|
+
$dec: 0;
|
|
12
|
+
@for $i from 1 through $length {
|
|
13
|
+
$factor: 1 + (15 * ($length - $i));
|
|
14
|
+
$index: index($hex, str-slice($string, $i, $i));
|
|
15
|
+
$dec: $dec + $factor * ($index - 1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@return $dec;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@function _from-hex($string) {
|
|
22
|
+
$string-lower: to-lower-case($string);
|
|
23
|
+
$r: ""; $g: ""; $b: ""; $a: "";
|
|
24
|
+
$hex: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f";
|
|
25
|
+
$length: str-length($string);
|
|
26
|
+
$max: if($length == 4, 1, 2);
|
|
27
|
+
|
|
28
|
+
// Check for length accuracy
|
|
29
|
+
@if $length != 4 and $length != 7 and $length != 9 {
|
|
30
|
+
@debug "Not accurate";
|
|
31
|
+
@return $string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Loop from the second character (omitting #)
|
|
35
|
+
@for $i from 2 through $length {
|
|
36
|
+
$c: str-slice($string-lower, $i, $i);
|
|
37
|
+
|
|
38
|
+
// If wrong character, return
|
|
39
|
+
@if index($hex, $c) == null {
|
|
40
|
+
@debug "Wrong character";
|
|
41
|
+
@return $string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@if str-length($r) < $max {
|
|
45
|
+
$r: $r + $c;
|
|
46
|
+
} @else if str-length($g) < $max {
|
|
47
|
+
$g: $g + $c;
|
|
48
|
+
} @else if str-length($b) < $max {
|
|
49
|
+
$b: $b + $c;
|
|
50
|
+
} @else if str-length($a) < $max {
|
|
51
|
+
$a: $a + $c;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@if $length == 4 {
|
|
56
|
+
$r: $r + $r;
|
|
57
|
+
$g: $g + $g;
|
|
58
|
+
$b: $b + $b;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@return rgba(_hex-to-dec($r), _hex-to-dec($g), _hex-to-dec($b),_hex-to-dec($a));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@function is-property($string) {
|
|
65
|
+
@return type-of($string) == "string" and str-index($string, "var") and str-index($string, ",");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@function str-trim($string) {
|
|
69
|
+
@if (str-slice($string, 1, 1) == ' ') {
|
|
70
|
+
@return str-trim(str-slice($string, 2));
|
|
71
|
+
} @else if (str-slice($string, str-length($string), -1) == ' ') {
|
|
72
|
+
@return str-trim(str-slice($string, 1, -2));
|
|
73
|
+
} @else {
|
|
74
|
+
@return $string;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@function extract-value($string) {
|
|
79
|
+
|
|
80
|
+
@if is-property-map($string) {
|
|
81
|
+
@return map-get($string,default);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@if not is-property($string) {
|
|
85
|
+
@return $string;
|
|
86
|
+
}
|
|
87
|
+
$result: str-slice($string,str-index($string,",")+1,str-index($string,")")-1);
|
|
88
|
+
|
|
89
|
+
@return str-trim($result);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@function extract-property($string) {
|
|
93
|
+
|
|
94
|
+
@if is-property-map($string) {
|
|
95
|
+
@return map-get($string,property);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@if not is-property($string) {
|
|
99
|
+
@return $string;
|
|
100
|
+
}
|
|
101
|
+
$result: str-slice($string, str-index($string,"--"),str-index($string,",")-1);
|
|
102
|
+
|
|
103
|
+
@return str-trim($result);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
@function guarantee-colour-value($string) {
|
|
107
|
+
@if is-property($string) {
|
|
108
|
+
$original: extract-value($string);
|
|
109
|
+
@return _from-hex($original);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@return $string;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@function is-property-map($value) {
|
|
116
|
+
@if type-of($value) == "map" and map-has-key($value,default) and map-has-key($value,property) {
|
|
117
|
+
@return true;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@return false;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@function build-colour-map($key, $colour) {
|
|
124
|
+
@return (
|
|
125
|
+
100: (property: --#{$key}--100, default: scale-color($colour,$lightness: -40%)),
|
|
126
|
+
200: (property: --#{$key}--200, default: scale-color($colour,$lightness: -30%)),
|
|
127
|
+
300: (property: --#{$key}--300, default: scale-color($colour,$lightness: -20%)),
|
|
128
|
+
400: (property: --#{$key}--400, default: scale-color($colour,$lightness: -10%)),
|
|
129
|
+
500: (property: --#{$key}, default: $colour),
|
|
130
|
+
600: (property: --#{$key}--600, default: scale-color($colour,$lightness: 10%)),
|
|
131
|
+
700: (property: --#{$key}--700, default: scale-color($colour,$lightness: 20%)),
|
|
132
|
+
800: (property: --#{$key}--800, default: scale-color($colour,$lightness: 30%)),
|
|
133
|
+
900: (property: --#{$key}--900, default: scale-color($colour,$lightness: 40%)),
|
|
134
|
+
muted: (property: --#{$key}--muted, default: change-color($colour,$lightness: 94%)),
|
|
135
|
+
muted2: (property: --#{$key}--muted2, default: change-color($colour,$lightness: 90%))
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
@function colour-property-from-map($map,$tint: 500) {
|
|
140
|
+
@return var(#{map-get(map-get($map,$tint),property)},#{map-get(map-get($map,$tint),default)});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@mixin define-global-property-alias($key, $property) {
|
|
144
|
+
@if is-property($property) or is-property-map($property) {
|
|
145
|
+
$_property: extract-property($property);
|
|
146
|
+
@at-root {
|
|
147
|
+
:root {
|
|
148
|
+
#{$key}: var(#{$_property});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@mixin define-global-property-alias-from-map($map,$keyPrefix: "", $keySuffix: "") {
|
|
155
|
+
@each $value, $key in $map {
|
|
156
|
+
@include define-global-property-alias(#{$keyPrefix}#{$key}#{$keySuffix},$value);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@mixin assign-variable-property($property, $value, $key: 0, $keyPrefix: "",$keySuffix: "") {
|
|
161
|
+
|
|
162
|
+
$_value: #{extract-value($value)};
|
|
163
|
+
|
|
164
|
+
// Fallback for browsers that don't support custom CSS properties
|
|
165
|
+
#{$property}: $_value;
|
|
166
|
+
@if variable-exists(slate-include-custom-properties) {
|
|
167
|
+
@if $key != 0 {
|
|
168
|
+
// Set value equal to generated custom property name, falling back to $_value if not defined
|
|
169
|
+
#{$property}: var(#{$keyPrefix}#{$key}#{$keySuffix}, $_value);
|
|
170
|
+
// Alias CSS custom property in :root so that values cascade by default
|
|
171
|
+
@if variable-exists(slate-autogenerate-global-property-aliases) {
|
|
172
|
+
@include define-global-property-alias(#{$keyPrefix}#{$key}#{$keySuffix},$value);
|
|
173
|
+
}
|
|
174
|
+
} @else if is-property($value) or is-property-map($value) {
|
|
175
|
+
// Assign the CSS custom property so that the value is inherited
|
|
176
|
+
$_customProperty: #{extract-property($value)};
|
|
177
|
+
#{$property}: var(#{$_customProperty}, $_value);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@mixin assign-variable-property-map($property,$map,$keyPrefix: "", $keySuffix:"") {
|
|
183
|
+
|
|
184
|
+
$fallback: ();
|
|
185
|
+
$output: ();
|
|
186
|
+
|
|
187
|
+
@each $value, $key in $map {
|
|
188
|
+
|
|
189
|
+
$_value: extract-value($value);
|
|
190
|
+
|
|
191
|
+
@if $key {
|
|
192
|
+
$output: append($output,var(#{$keyPrefix}#{$key}#{$keySuffix},#{$_value}));
|
|
193
|
+
@if variable-exists(slate-autogenerate-global-property-aliases) {
|
|
194
|
+
// Alias CSS custom property in :root so that values cascade
|
|
195
|
+
@include define-global-property-alias(#{$keyPrefix}#{$key}#{$keySuffix},$value);
|
|
196
|
+
}
|
|
197
|
+
} @else {
|
|
198
|
+
$output: append($output,#{$_value});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
$fallback: append($fallback,#{$_value});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
#{$property}: $fallback;
|
|
205
|
+
@if variable-exists(slate-include-custom-properties) {
|
|
206
|
+
#{$property}: $output;
|
|
207
|
+
}
|
|
208
|
+
}
|