@pingux/astro 2.5.5 → 2.5.6-alpha.1
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/lib/cjs/components/Menu/Menu.js +0 -7
- package/lib/cjs/components/Menu/Menu.stories.js +5 -0
- package/lib/cjs/components/Messages/Messages.js +0 -5
- package/lib/cjs/components/Messages/Messages.stories.js +5 -0
- package/lib/cjs/components/Modal/Modal.js +0 -6
- package/lib/cjs/components/Modal/Modal.stories.js +9 -0
- package/lib/cjs/components/NavBar/NavBar.js +0 -10
- package/lib/cjs/components/NavBar/NavBar.stories.js +10 -1
- package/lib/cjs/components/OverlayPanel/OverlayPanel.js +0 -8
- package/lib/cjs/components/OverlayPanel/OverlayPanel.stories.js +5 -0
- package/lib/cjs/components/PopoverMenu/PopoverMenu.js +0 -6
- package/lib/cjs/components/PopoverMenu/PopoverMenu.stories.js +5 -0
- package/lib/cjs/components/RequirementsList/RequirementsList.js +0 -5
- package/lib/cjs/components/RequirementsList/RequirementsList.stories.js +17 -8
- package/lib/cjs/components/RockerButton/RockerButton.js +30 -9
- package/lib/cjs/components/RockerButton/RockerButton.styles.js +6 -3
- package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.js +0 -5
- package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.stories.js +5 -0
- package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.test.js +40 -1
- package/lib/cjs/styles/colors.js +22 -3
- package/lib/components/Menu/Menu.js +0 -7
- package/lib/components/Menu/Menu.stories.js +5 -0
- package/lib/components/Messages/Messages.js +0 -5
- package/lib/components/Messages/Messages.stories.js +5 -0
- package/lib/components/Modal/Modal.js +0 -6
- package/lib/components/Modal/Modal.stories.js +9 -0
- package/lib/components/NavBar/NavBar.js +0 -10
- package/lib/components/NavBar/NavBar.stories.js +10 -1
- package/lib/components/OverlayPanel/OverlayPanel.js +0 -8
- package/lib/components/OverlayPanel/OverlayPanel.stories.js +5 -0
- package/lib/components/PopoverMenu/PopoverMenu.js +0 -7
- package/lib/components/PopoverMenu/PopoverMenu.stories.js +5 -0
- package/lib/components/RequirementsList/RequirementsList.js +0 -5
- package/lib/components/RequirementsList/RequirementsList.stories.js +17 -8
- package/lib/components/RockerButton/RockerButton.js +30 -9
- package/lib/components/RockerButton/RockerButton.styles.js +6 -3
- package/lib/components/RockerButtonGroup/RockerButtonGroup.js +0 -6
- package/lib/components/RockerButtonGroup/RockerButtonGroup.stories.js +5 -0
- package/lib/components/RockerButtonGroup/RockerButtonGroup.test.js +40 -1
- package/lib/styles/colors.js +18 -1
- package/package.json +1 -1
- package/NOTICE.html +0 -12821
@@ -18,9 +18,11 @@ import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values"
|
|
18
18
|
import React, { useEffect, useReducer, useState } from 'react';
|
19
19
|
import { Item } from 'react-stately';
|
20
20
|
import AccountIcon from 'mdi-react/AccountIcon';
|
21
|
+
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
21
22
|
import { Box, Button, Messages } from '../../index';
|
22
23
|
import statuses from '../../utils/devUtils/constants/statuses';
|
23
24
|
import { messagesReducerStory as messagesReducer, multiMessagesReducerStory as multiMessagesReducer } from './index';
|
25
|
+
import MessagesReadme from './Messages.mdx';
|
24
26
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
25
27
|
export default {
|
26
28
|
title: 'Components/Messages',
|
@@ -39,6 +41,9 @@ export default {
|
|
39
41
|
},
|
40
42
|
parameters: {
|
41
43
|
docs: {
|
44
|
+
page: function page() {
|
45
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(MessagesReadme, null), ___EmotionJSX(DocsLayout, null));
|
46
|
+
},
|
42
47
|
source: {
|
43
48
|
type: 'code'
|
44
49
|
}
|
@@ -23,12 +23,6 @@ import Box from '../Box';
|
|
23
23
|
import Icon from '../Icon';
|
24
24
|
import IconButton from '../IconButton';
|
25
25
|
import Text from '../Text';
|
26
|
-
|
27
|
-
/**
|
28
|
-
* Modals are overlays that interrupt a user’s workflow to convey an important message.
|
29
|
-
* The component must be wrapped in an OverlayProvider, and the first child should be a trigger,
|
30
|
-
* such as Button.
|
31
|
-
*/
|
32
26
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
33
27
|
var Modal = /*#__PURE__*/forwardRef(function (props, ref) {
|
34
28
|
var className = props.className,
|
@@ -1,12 +1,21 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import React from 'react';
|
3
|
+
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
3
4
|
import { useModalState } from '../../hooks';
|
4
5
|
import { Box, Button, Modal, OverlayProvider, Text } from '../../index';
|
5
6
|
import { modalSizes } from '../../utils/devUtils/constants/modalSizes';
|
7
|
+
import ModalReadme from './Modal.mdx';
|
6
8
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
7
9
|
export default {
|
8
10
|
title: 'Components/Modal',
|
9
11
|
component: Modal,
|
12
|
+
parameters: {
|
13
|
+
docs: {
|
14
|
+
page: function page() {
|
15
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(ModalReadme, null), ___EmotionJSX(DocsLayout, null));
|
16
|
+
}
|
17
|
+
}
|
18
|
+
},
|
10
19
|
argTypes: {
|
11
20
|
title: {
|
12
21
|
control: {
|
@@ -12,16 +12,6 @@ import useNavBarStyling from '../../hooks/useNavBarStyling/useNavBarStyling';
|
|
12
12
|
import useProgressiveState from '../../hooks/useProgressiveState';
|
13
13
|
import { isIterableProp } from '../../utils/devUtils/props/isIterable';
|
14
14
|
import Box from '../Box/Box';
|
15
|
-
|
16
|
-
/**
|
17
|
-
* Composed component that spreads children.
|
18
|
-
*
|
19
|
-
* This component is built to have the NavBarSection component passed into it.
|
20
|
-
*
|
21
|
-
* NavBarSection is an iterative component that using
|
22
|
-
* an array of objects that is passed into it.
|
23
|
-
*
|
24
|
-
*/
|
25
15
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
26
16
|
var NavBar = function NavBar(props) {
|
27
17
|
var defaultSelectedKey = props.defaultSelectedKey,
|
@@ -11,7 +11,9 @@ import ScaleBalance from 'mdi-react/ScaleBalanceIcon';
|
|
11
11
|
import TransitConnection from 'mdi-react/TransitConnectionVariantIcon';
|
12
12
|
import ViewDashboard from 'mdi-react/ViewDashboardIcon';
|
13
13
|
import ViewGridPlusOutline from 'mdi-react/ViewGridPlusOutlineIcon';
|
14
|
+
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
14
15
|
import { Box, Link, NavBar, NavBarItem, NavBarItemButton, NavBarItemLink, NavBarSection, Separator } from '../../index';
|
16
|
+
import NavBarReadme from './NavBar.mdx';
|
15
17
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
16
18
|
export default {
|
17
19
|
component: NavBar,
|
@@ -20,7 +22,14 @@ export default {
|
|
20
22
|
NavBarItemLink: NavBarItemLink,
|
21
23
|
NavBarItemButton: NavBarItemButton
|
22
24
|
},
|
23
|
-
title: 'Components/NavBar'
|
25
|
+
title: 'Components/NavBar',
|
26
|
+
parameters: {
|
27
|
+
docs: {
|
28
|
+
page: function page() {
|
29
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(NavBarReadme, null), ___EmotionJSX(DocsLayout, null));
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
24
33
|
};
|
25
34
|
var Credentials = function Credentials(props) {
|
26
35
|
return ___EmotionJSX("svg", _extends({
|
@@ -9,14 +9,6 @@ import PropTypes from 'prop-types';
|
|
9
9
|
import { Box } from '../..';
|
10
10
|
import { useOverlayPanelState, useStatusClasses } from '../../hooks';
|
11
11
|
import { panelSizes } from '../../utils/devUtils/constants/panelSizes';
|
12
|
-
|
13
|
-
/**
|
14
|
-
* In Astro, side panels are used to show details and present modal interactions.
|
15
|
-
*
|
16
|
-
* Note: The way the OverlayPanel displays in the Firefox browser differs from other browsers.
|
17
|
-
* This is a Storybook only issue and will not effect the way it works in your app. Be sure to
|
18
|
-
* use Chrome or Safari to view how this component works.
|
19
|
-
*/
|
20
12
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
21
13
|
var OverlayPanel = /*#__PURE__*/forwardRef(function (props, ref) {
|
22
14
|
var _props$sx;
|
@@ -9,10 +9,12 @@ import ArrowTopRightBottomLeft from 'mdi-react/ArrowTopRightBottomLeftIcon';
|
|
9
9
|
import ChevronRightIcon from 'mdi-react/ChevronRightIcon';
|
10
10
|
import CloseIcon from 'mdi-react/CloseIcon';
|
11
11
|
import CogIcon from 'mdi-react/CogIcon';
|
12
|
+
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
12
13
|
import { useOverlayPanelState } from '../../hooks';
|
13
14
|
import { Avatar, Box, Breadcrumbs, Button, ColorField, IconButton, MultivaluesField, OverlayPanel, OverlayProvider, SwitchField, Tab, Tabs, Text, TextField } from '../../index';
|
14
15
|
import { pingImg } from '../../utils/devUtils/constants/images';
|
15
16
|
import { panelSizes } from '../../utils/devUtils/constants/panelSizes';
|
17
|
+
import OverlayPanelReadme from './OverlayPanel.mdx';
|
16
18
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
17
19
|
export default {
|
18
20
|
title: 'Components/OverlayPanel',
|
@@ -35,6 +37,9 @@ export default {
|
|
35
37
|
},
|
36
38
|
parameters: {
|
37
39
|
docs: {
|
40
|
+
page: function page() {
|
41
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(OverlayPanelReadme, null), ___EmotionJSX(DocsLayout, null));
|
42
|
+
},
|
38
43
|
source: {
|
39
44
|
type: 'code'
|
40
45
|
}
|
@@ -19,13 +19,6 @@ import { PressResponder } from '@react-aria/interactions';
|
|
19
19
|
import PropTypes from 'prop-types';
|
20
20
|
import { MenuContext } from '../../context/MenuContext';
|
21
21
|
import PopoverContainer from '../PopoverContainer';
|
22
|
-
|
23
|
-
/**
|
24
|
-
* The PopoverMenu serves as a wrapper around a Menu and its associated trigger, linking the Menu's
|
25
|
-
* open state with the trigger's press state and providing necessary overlay context.
|
26
|
-
*
|
27
|
-
* Primarily utilizes [useMenuTrigger](https://react-spectrum.adobe.com/react-aria/useMenuTrigger.html) from React Aria and [useMenuTriggerState](https://react-spectrum.adobe.com/react-stately/useMenuTriggerState.html) from React Stately.
|
28
|
-
*/
|
29
22
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
30
23
|
var PopoverMenu = /*#__PURE__*/forwardRef(function (props, ref) {
|
31
24
|
var _context;
|
@@ -1,13 +1,18 @@
|
|
1
1
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
2
2
|
import React, { useState } from 'react';
|
3
3
|
import { action } from '@storybook/addon-actions';
|
4
|
+
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
4
5
|
import { Button, Item, Menu, OverlayProvider, PopoverMenu, Text } from '../../index';
|
6
|
+
import PopoverMenuReadme from './PopoverMenu.mdx';
|
5
7
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
6
8
|
export default {
|
7
9
|
title: 'Components/PopoverMenu',
|
8
10
|
component: PopoverMenu,
|
9
11
|
parameters: {
|
10
12
|
docs: {
|
13
|
+
page: function page() {
|
14
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(PopoverMenuReadme, null), ___EmotionJSX(DocsLayout, null));
|
15
|
+
},
|
11
16
|
source: {
|
12
17
|
type: 'code'
|
13
18
|
}
|
@@ -24,11 +24,6 @@ import { statusPropTypes } from '../../utils/docUtils/statusProp';
|
|
24
24
|
import Box from '../Box';
|
25
25
|
import Icon from '../Icon';
|
26
26
|
import Text from '../Text';
|
27
|
-
|
28
|
-
/**
|
29
|
-
* List of requirements for a password, with indicators that can change to show when
|
30
|
-
* requirements are satisfied.
|
31
|
-
*/
|
32
27
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
33
28
|
var RequirementsList = /*#__PURE__*/forwardRef(function (props, ref) {
|
34
29
|
var requirements = props.requirements,
|
@@ -1,26 +1,35 @@
|
|
1
1
|
import React from 'react';
|
2
|
+
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
2
3
|
import { RequirementsList } from '../../index';
|
4
|
+
import RequirementsListReadme from './RequirementsList.mdx';
|
3
5
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
4
6
|
export default {
|
5
7
|
title: 'Components/RequirementsList',
|
6
8
|
component: RequirementsList,
|
9
|
+
parameters: {
|
10
|
+
docs: {
|
11
|
+
page: function page() {
|
12
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(RequirementsListReadme, null), ___EmotionJSX(DocsLayout, null));
|
13
|
+
}
|
14
|
+
}
|
15
|
+
},
|
7
16
|
argTypes: {
|
8
17
|
requirements: {
|
9
18
|
control: {
|
10
19
|
type: 'object'
|
11
20
|
},
|
12
21
|
defaultValue: [{
|
13
|
-
|
14
|
-
|
22
|
+
name: 'requirement 1',
|
23
|
+
status: 'default'
|
15
24
|
}, {
|
16
|
-
|
17
|
-
|
25
|
+
name: 'requirement 2',
|
26
|
+
status: 'warning'
|
18
27
|
}, {
|
19
|
-
|
20
|
-
|
28
|
+
name: 'requirement 3',
|
29
|
+
status: 'error'
|
21
30
|
}, {
|
22
|
-
|
23
|
-
|
31
|
+
name: 'requirement 4',
|
32
|
+
status: 'success'
|
24
33
|
}],
|
25
34
|
description: 'Requirements and their status.'
|
26
35
|
}
|
@@ -13,12 +13,16 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
13
13
|
import React, { forwardRef, useContext, useImperativeHandle, useRef } from 'react';
|
14
14
|
import { FocusRing } from 'react-aria';
|
15
15
|
import { Item } from 'react-stately';
|
16
|
+
import { useHover, usePress } from '@react-aria/interactions';
|
17
|
+
import { mergeProps } from '@react-aria/utils';
|
16
18
|
import PropTypes from 'prop-types';
|
17
19
|
import { usePropWarning, useRockerButton, useStatusClasses } from '../../hooks';
|
18
20
|
import { Box } from '../../index';
|
21
|
+
import { accent, getBaseHexColor, getDarkerColor } from '../../styles/colors';
|
19
22
|
import { RockerContext } from '../RockerButtonGroup';
|
20
23
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
21
24
|
export var CollectionRockerButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
25
|
+
var _itemProps$selectedSt, _itemProps$selectedSt2;
|
22
26
|
var className = props.className,
|
23
27
|
item = props.item;
|
24
28
|
var key = item.key,
|
@@ -27,12 +31,21 @@ export var CollectionRockerButton = /*#__PURE__*/forwardRef(function (props, ref
|
|
27
31
|
var state = useContext(RockerContext);
|
28
32
|
var isDisabled = state.disabledKeys.has(key);
|
29
33
|
var isSelected = state.selectedKey === key;
|
34
|
+
var rockerButtonRef = useRef();
|
35
|
+
var _useHover = useHover({}),
|
36
|
+
hoverProps = _useHover.hoverProps,
|
37
|
+
isHovered = _useHover.isHovered;
|
38
|
+
var _usePress = usePress(rockerButtonRef),
|
39
|
+
pressProps = _usePress.pressProps,
|
40
|
+
isPressed = _usePress.isPressed;
|
30
41
|
var _useStatusClasses = useStatusClasses(className, {
|
42
|
+
isHovered: isHovered,
|
43
|
+
isPressed: isPressed,
|
31
44
|
isSelected: isSelected,
|
32
45
|
isDisabled: isDisabled
|
33
46
|
}),
|
34
47
|
classNames = _useStatusClasses.classNames;
|
35
|
-
var
|
48
|
+
var backgroundHexColor = (_itemProps$selectedSt = itemProps.selectedStyles) !== null && _itemProps$selectedSt !== void 0 && _itemProps$selectedSt.bg ? getBaseHexColor((_itemProps$selectedSt2 = itemProps.selectedStyles) === null || _itemProps$selectedSt2 === void 0 ? void 0 : _itemProps$selectedSt2.bg) : accent[20];
|
36
49
|
usePropWarning(props, 'disabled', 'isDisabled');
|
37
50
|
/* istanbul ignore next */
|
38
51
|
useImperativeHandle(ref, function () {
|
@@ -49,25 +62,33 @@ export var CollectionRockerButton = /*#__PURE__*/forwardRef(function (props, ref
|
|
49
62
|
}, ___EmotionJSX(Box, _extends({
|
50
63
|
as: "button",
|
51
64
|
className: classNames,
|
52
|
-
variant: "variants.rockerButton.thumbSwitch"
|
53
|
-
|
54
|
-
ref: rockerButtonRef
|
55
|
-
}, itemProps, {
|
65
|
+
variant: "variants.rockerButton.thumbSwitch",
|
66
|
+
ref: rockerButtonRef,
|
56
67
|
sx: {
|
57
|
-
'&.is-selected': _objectSpread({}, itemProps.selectedStyles)
|
68
|
+
'&.is-selected': _objectSpread({}, itemProps.selectedStyles),
|
69
|
+
'&.is-selected.is-hovered': {
|
70
|
+
bg: getDarkerColor(backgroundHexColor, 0.2)
|
71
|
+
},
|
72
|
+
'&.is-selected.is-pressed': {
|
73
|
+
bg: getDarkerColor(backgroundHexColor, 0.4)
|
74
|
+
}
|
58
75
|
}
|
59
|
-
}), rendered));
|
76
|
+
}, mergeProps(hoverProps, pressProps, itemProps, rockerButtonProps)), rendered));
|
60
77
|
});
|
61
78
|
CollectionRockerButton.displayName = 'CollectionRockerButton';
|
62
79
|
CollectionRockerButton.propTypes = {
|
63
80
|
/** Allows custom styles to be passed to button. */
|
64
|
-
selectedStyles: PropTypes.shape({
|
81
|
+
selectedStyles: PropTypes.shape({
|
82
|
+
bg: PropTypes.string
|
83
|
+
}),
|
65
84
|
// adding to surface in props table
|
66
85
|
/** @ignore */
|
67
86
|
item: PropTypes.shape({
|
68
87
|
key: PropTypes.string,
|
69
88
|
props: PropTypes.shape({
|
70
|
-
selectedStyles: PropTypes.shape({
|
89
|
+
selectedStyles: PropTypes.shape({
|
90
|
+
bg: PropTypes.string
|
91
|
+
})
|
71
92
|
}),
|
72
93
|
rendered: PropTypes.node
|
73
94
|
})
|
@@ -26,7 +26,7 @@ var thumbSwitch = _objectSpread(_objectSpread({}, base), {}, {
|
|
26
26
|
display: 'inline-flex',
|
27
27
|
height: '26px',
|
28
28
|
lineHeight: '26px',
|
29
|
-
fontSize: '
|
29
|
+
fontSize: '13px',
|
30
30
|
borderRadius: '15px',
|
31
31
|
alignSelf: 'center',
|
32
32
|
paddingTop: '0px',
|
@@ -34,11 +34,14 @@ var thumbSwitch = _objectSpread(_objectSpread({}, base), {}, {
|
|
34
34
|
textTransform: 'uppercase',
|
35
35
|
bg: 'accent.95',
|
36
36
|
'&.is-selected': {
|
37
|
-
bg: '
|
37
|
+
bg: 'accent.20',
|
38
38
|
color: 'white',
|
39
39
|
zIndex: '1'
|
40
40
|
},
|
41
|
-
'&.is-focused': _objectSpread({}, defaultFocus)
|
41
|
+
'&.is-focused': _objectSpread({}, defaultFocus),
|
42
|
+
'&.is-hovered': {
|
43
|
+
bg: 'white'
|
44
|
+
}
|
42
45
|
});
|
43
46
|
export default {
|
44
47
|
container: container,
|
@@ -23,12 +23,6 @@ import Box from '../Box';
|
|
23
23
|
import { CollectionRockerButton } from '../RockerButton';
|
24
24
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
25
25
|
export var RockerContext = /*#__PURE__*/React.createContext({});
|
26
|
-
|
27
|
-
/**
|
28
|
-
* This component handles a single selection state for a group of rocker buttons.
|
29
|
-
* It is intended to be used with < RockerButton > as children.
|
30
|
-
*/
|
31
|
-
|
32
26
|
var RockerButtonGroup = /*#__PURE__*/forwardRef(function (props, ref) {
|
33
27
|
var _context;
|
34
28
|
var children = props.children,
|
@@ -2,13 +2,18 @@ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
|
2
2
|
import _objectDestructuringEmpty from "@babel/runtime-corejs3/helpers/esm/objectDestructuringEmpty";
|
3
3
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
4
4
|
import React, { useState } from 'react';
|
5
|
+
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
5
6
|
import { RockerButton, RockerButtonGroup } from '../../index';
|
7
|
+
import RockerButtonGroupReadme from './RockerButtonGroup.mdx';
|
6
8
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
7
9
|
export default {
|
8
10
|
title: 'Components/RockerButtonGroup',
|
9
11
|
component: RockerButtonGroup,
|
10
12
|
parameters: {
|
11
13
|
docs: {
|
14
|
+
page: function page() {
|
15
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(RockerButtonGroupReadme, null), ___EmotionJSX(DocsLayout, null));
|
16
|
+
},
|
12
17
|
source: {
|
13
18
|
type: 'code'
|
14
19
|
}
|
@@ -16,7 +16,10 @@ var testButtons = [{
|
|
16
16
|
}
|
17
17
|
}, {
|
18
18
|
name: 'Or',
|
19
|
-
key: 'Or'
|
19
|
+
key: 'Or',
|
20
|
+
selectedStyles: {
|
21
|
+
bg: 'accent.30'
|
22
|
+
}
|
20
23
|
}, {
|
21
24
|
name: 'Maybe?',
|
22
25
|
key: 'Maybe?'
|
@@ -90,4 +93,40 @@ test('selected button can be changed by keyboard interaction', function () {
|
|
90
93
|
});
|
91
94
|
expect(screen.getByText(testButtons[1].key)).toHaveClass('is-selected');
|
92
95
|
expect(screen.getByText(testButtons[0].key)).not.toHaveClass('is-selected');
|
96
|
+
});
|
97
|
+
test('rockerButton renders correct darker bg when selectedStyles prop is passed', function () {
|
98
|
+
getComponent();
|
99
|
+
var button0 = screen.getByText(testButtons[0].key);
|
100
|
+
expect(button0).toHaveClass('is-selected');
|
101
|
+
expect(button0).toHaveStyle('background-color: #640099');
|
102
|
+
userEvent.hover(button0);
|
103
|
+
expect(button0).toHaveClass('is-selected');
|
104
|
+
expect(button0).toHaveClass('is-hovered');
|
105
|
+
expect(button0).toHaveStyle('background-color: #590089');
|
106
|
+
fireEvent.keyDown(button0, {
|
107
|
+
key: 'Enter',
|
108
|
+
code: 13
|
109
|
+
});
|
110
|
+
expect(button0).toHaveClass('is-selected');
|
111
|
+
expect(button0).toHaveClass('is-pressed');
|
112
|
+
expect(button0).toHaveStyle('background-color: #4d0077');
|
113
|
+
});
|
114
|
+
test('rockerButton renders correct bg when selectedStyles prop is css variable', function () {
|
115
|
+
getComponent();
|
116
|
+
var button1 = screen.getByText(testButtons[1].key);
|
117
|
+
fireEvent.keyDown(screen.getByText(testButtons[0].key), {
|
118
|
+
key: 'ArrowRight',
|
119
|
+
code: 'ArrowRight'
|
120
|
+
});
|
121
|
+
userEvent.hover(button1);
|
122
|
+
expect(button1).toHaveClass('is-selected');
|
123
|
+
expect(button1).toHaveClass('is-hovered');
|
124
|
+
expect(button1).toHaveStyle('background-color: #364872');
|
125
|
+
fireEvent.keyDown(button1, {
|
126
|
+
key: 'Enter',
|
127
|
+
code: 13
|
128
|
+
});
|
129
|
+
expect(button1).toHaveClass('is-selected');
|
130
|
+
expect(button1).toHaveClass('is-pressed');
|
131
|
+
expect(button1).toHaveStyle('background-color: #2e3e63');
|
93
132
|
});
|
package/lib/styles/colors.js
CHANGED
@@ -6,6 +6,7 @@ import _fillInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instanc
|
|
6
6
|
import _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
|
7
7
|
import _Object$entries from "@babel/runtime-corejs3/core-js-stable/object/entries";
|
8
8
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
9
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
9
10
|
import chroma from 'chroma-js';
|
10
11
|
|
11
12
|
// SEMANTIC COLORS
|
@@ -83,6 +84,9 @@ export var decorativeDark = _mapInstanceProperty(decorative).call(decorative, fu
|
|
83
84
|
export var decorativeLight = _mapInstanceProperty(decorative).call(decorative, function (color) {
|
84
85
|
return chroma(color).brighten(2).hex();
|
85
86
|
});
|
87
|
+
export var getDarkerColor = function getDarkerColor(color, percentage) {
|
88
|
+
return chroma.valid(color) ? chroma.mix(color, '#000000', percentage).hex() : '';
|
89
|
+
};
|
86
90
|
|
87
91
|
// export const focus = chroma(accent[50]).alpha(0.75).hex();
|
88
92
|
export var focus = chroma('#D033FF').hex();
|
@@ -152,4 +156,17 @@ function flattenColors(obj) {
|
|
152
156
|
}
|
153
157
|
|
154
158
|
/* used by Storybook's stories */
|
155
|
-
export var flatColorList = flattenColors(allColors);
|
159
|
+
export var flatColorList = flattenColors(allColors);
|
160
|
+
export var getBaseHexColor = function getBaseHexColor(colorName) {
|
161
|
+
if (chroma.valid(colorName)) {
|
162
|
+
return colorName;
|
163
|
+
}
|
164
|
+
try {
|
165
|
+
var keys = _includesInstanceProperty(colorName).call(colorName, '.') ? colorName.split('.') : [colorName];
|
166
|
+
return _reduceInstanceProperty(keys).call(keys, function (obj, key) {
|
167
|
+
return obj[key];
|
168
|
+
}, allColors);
|
169
|
+
} catch (error) {
|
170
|
+
return accentBase;
|
171
|
+
}
|
172
|
+
};
|