@ndlib/component-library 0.0.30 → 0.0.32
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/dist/components/composites/Card/Card.stories.d.ts +2 -0
- package/dist/components/composites/Card/Card.stories.js +27 -0
- package/dist/components/composites/Card/Card.test.js +8 -0
- package/dist/components/composites/Card/index.d.ts +5 -1
- package/dist/components/composites/Card/index.js +16 -11
- package/dist/components/composites/EmptyState/index.js +1 -1
- package/dist/components/composites/NavMenu/index.js +1 -1
- package/dist/components/elements/ArrowLink/ArrowLink.stories.d.ts +6 -0
- package/dist/components/elements/ArrowLink/ArrowLink.stories.js +12 -0
- package/dist/components/elements/ArrowLink/ArrowLink.test.d.ts +1 -0
- package/dist/components/elements/ArrowLink/ArrowLink.test.js +34 -0
- package/dist/components/elements/ArrowLink/index.d.ts +8 -0
- package/dist/components/elements/ArrowLink/index.js +39 -0
- package/dist/components/elements/Button/Button.stories.d.ts +1 -0
- package/dist/components/elements/Button/Button.stories.js +12 -3
- package/dist/components/elements/Button/index.d.ts +20 -1
- package/dist/components/elements/Button/index.js +26 -55
- package/dist/components/elements/Fields/AutoComplete/AutoComplete.stories.d.ts +6 -0
- package/dist/components/elements/Fields/AutoComplete/AutoComplete.stories.js +60 -0
- package/dist/components/elements/Fields/AutoComplete/index.d.ts +11 -0
- package/dist/components/elements/Fields/AutoComplete/index.js +26 -0
- package/dist/components/elements/Fields/Select/index.js +3 -3
- package/dist/components/elements/Fields/TextInput/index.d.ts +1 -1
- package/dist/components/elements/Fields/TextInput/index.js +1 -1
- package/dist/components/elements/ListBox/index.d.ts +3 -3
- package/dist/components/elements/ListBox/index.js +5 -3
- package/dist/components/elements/Pill/index.d.ts +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/theme/Color.stories.js +10 -4
- package/dist/theme/colors.d.ts +12 -3
- package/dist/theme/colors.js +28 -10
- package/dist/theme/index.d.ts +25 -7
- package/package.json +1 -1
|
@@ -2,9 +2,11 @@ import { createElement as _createElement } from "react";
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import AccessTime from '@mui/icons-material/AccessTimeFilled';
|
|
4
4
|
import CalendarIcon from '@mui/icons-material/CalendarMonth';
|
|
5
|
+
import BookmarkIcon from '@mui/icons-material/Bookmark';
|
|
5
6
|
import { CARD_LAYOUT, CARD_SIZE, Card } from '.';
|
|
6
7
|
import { COLOR, Column, LABEL_SIZE, Label, Paragraph, ReadMore, TYPOGRAPHY_TYPE, } from '../../..';
|
|
7
8
|
import { Icon } from '../../elements/Icon';
|
|
9
|
+
import { BUTTON_TYPE, Button } from '../../elements/Button';
|
|
8
10
|
const meta = {
|
|
9
11
|
title: 'Composites/Card',
|
|
10
12
|
component: Card,
|
|
@@ -16,21 +18,33 @@ const headlinedCards = [
|
|
|
16
18
|
headline: 'Exhibit — Printing the Nation: A Century of Irish Book Arts',
|
|
17
19
|
image: 'https://images.ctfassets.net/cfblb1f7i85j/7aCd5Sm86JdtQepGBKDUfy/dcb4d97dd3a1d3ee810e8bcaa82dc715/Spring_Exhibit_2023-Rep.jpg?w=296',
|
|
18
20
|
size: CARD_SIZE.SM,
|
|
21
|
+
sx: {
|
|
22
|
+
width: '500px',
|
|
23
|
+
},
|
|
19
24
|
},
|
|
20
25
|
{
|
|
21
26
|
headline: 'One Book, One Michiana Digital Exhibit — Papers Alight: Contextualizing Mike Curato’s Flamer. Other text to make this longer than the other card.',
|
|
22
27
|
image: 'https://images.ctfassets.net/cfblb1f7i85j/2sGpdDbNkl6MPnlem6wq1R/995c786624613b5ff07228e481996385/One.Book.2023-Rep.png?w=296',
|
|
23
28
|
size: CARD_SIZE.SM,
|
|
29
|
+
sx: {
|
|
30
|
+
width: '500px',
|
|
31
|
+
},
|
|
24
32
|
},
|
|
25
33
|
];
|
|
26
34
|
const basicCards = [
|
|
27
35
|
{
|
|
28
36
|
children: _jsx(Paragraph, { children: "Basic card 1" }),
|
|
29
37
|
size: CARD_SIZE.SM,
|
|
38
|
+
sx: {
|
|
39
|
+
width: '500px',
|
|
40
|
+
},
|
|
30
41
|
},
|
|
31
42
|
{
|
|
32
43
|
children: _jsx(Paragraph, { children: "Basic card 2" }),
|
|
33
44
|
size: CARD_SIZE.SM,
|
|
45
|
+
sx: {
|
|
46
|
+
width: '500px',
|
|
47
|
+
},
|
|
34
48
|
},
|
|
35
49
|
];
|
|
36
50
|
const dateCards = [
|
|
@@ -93,3 +107,16 @@ export const Raised = {
|
|
|
93
107
|
render: () => (_jsx(Column, { children: basicCards.map((props, i) => (_createElement(Card, Object.assign({}, props, { raised: true, key: i })))) })),
|
|
94
108
|
args: {},
|
|
95
109
|
};
|
|
110
|
+
export const Heading = {
|
|
111
|
+
render: () => (_jsx(Column, { children: basicCards.map((props, i) => (_createElement(Card, Object.assign({}, props, { key: i, heading: "Heading", headingIcon: BookmarkIcon, headingAction: _jsx(Button, Object.assign({ type: BUTTON_TYPE.TEXT, color: COLOR.WHITE, onClick: () => { } }, { children: "Click Me" })) })))) })),
|
|
112
|
+
args: {},
|
|
113
|
+
};
|
|
114
|
+
export const CustomImageHeading = {
|
|
115
|
+
render: () => (_jsx(Column, { children: basicCards.map((props, i) => (_createElement(Card, Object.assign({}, props, { key: i, heading: "Heading", headingStyles: {
|
|
116
|
+
backgroundImage: `url(https://library.nd.edu/static/media/jesus.2.4a2b137e.png)`,
|
|
117
|
+
backgroundRepeat: 'no-repeat',
|
|
118
|
+
backgroundPositionX: 'right',
|
|
119
|
+
backgrounndPositionY: '-15px',
|
|
120
|
+
} })))) })),
|
|
121
|
+
args: {},
|
|
122
|
+
};
|
|
@@ -26,4 +26,12 @@ describe('Card', () => {
|
|
|
26
26
|
});
|
|
27
27
|
expect(mockClickHandler).toBeCalledTimes(2);
|
|
28
28
|
});
|
|
29
|
+
it('labels card with headline when passed', () => {
|
|
30
|
+
const { getByLabelText } = render(_jsx(Card, { headline: MOCK_HEADLINE }));
|
|
31
|
+
expect(getByLabelText(MOCK_HEADLINE)).toBeDefined();
|
|
32
|
+
});
|
|
33
|
+
it('labels card with heading when passed', () => {
|
|
34
|
+
const { getByLabelText } = render(_jsx(Card, { heading: MOCK_HEADLINE }));
|
|
35
|
+
expect(getByLabelText(MOCK_HEADLINE)).toBeDefined();
|
|
36
|
+
});
|
|
29
37
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StyledElementProps } from '../../../theme';
|
|
1
|
+
import { StyledElementProps, StylesProp } from '../../../theme';
|
|
2
2
|
import { COLOR } from '../../../theme/colors';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
export declare enum CARD_LAYOUT {
|
|
@@ -17,6 +17,10 @@ type CardState = {
|
|
|
17
17
|
type CardChildren = React.ReactNode | ((state: CardState) => React.ReactNode);
|
|
18
18
|
export type CardProps = StyledElementProps<HTMLDivElement, {
|
|
19
19
|
headline?: string;
|
|
20
|
+
heading?: string;
|
|
21
|
+
headingStyles?: StylesProp;
|
|
22
|
+
headingIcon?: React.FC;
|
|
23
|
+
headingAction?: React.ReactNode;
|
|
20
24
|
truncateHeadlineAfter?: number;
|
|
21
25
|
body?: React.ReactNode;
|
|
22
26
|
image?: string;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Heading } from '../../elements/text/Heading';
|
|
2
|
+
import { HEADING_SIZE, Heading } from '../../elements/text/Heading';
|
|
3
3
|
import { ReadMore } from '../../elements/text/ReadMore';
|
|
4
4
|
import { useTheme } from '../../../theme';
|
|
5
5
|
import { GROUP_TYPE, Group } from '../../elements/Group';
|
|
6
6
|
import { Box } from '../../elements/layout/Box';
|
|
7
|
+
import { Icon } from '../../elements/Icon';
|
|
7
8
|
import { Column, FONT, FONT_SIZE, Row, TYPOGRAPHY_TYPE } from '../../..';
|
|
8
9
|
import { COLOR } from '../../../theme/colors';
|
|
9
10
|
import React, { useEffect, useState } from 'react';
|
|
@@ -51,10 +52,9 @@ const DateDisplay = ({ date: dateString }) => {
|
|
|
51
52
|
mt: 1,
|
|
52
53
|
} }, { children: MONTH_LABELS[date.getMonth()] }))] })));
|
|
53
54
|
};
|
|
54
|
-
export const Card = ({ size, displayDate, headline, image, layout, onClick, raised, truncateHeadlineAfter, sx, children, }) => {
|
|
55
|
+
export const Card = ({ size, displayDate, headline, image, layout, onClick, raised, truncateHeadlineAfter, heading, headingStyles, headingIcon, headingAction, sx, children, }) => {
|
|
55
56
|
const theme = useTheme();
|
|
56
|
-
const contentPaddingX = size === CARD_SIZE.SM ?
|
|
57
|
-
const bodyTopMargin = size === CARD_SIZE.SM ? 2 : 3;
|
|
57
|
+
const contentPaddingX = size === CARD_SIZE.SM ? 3 : 4;
|
|
58
58
|
const isVertical = !layout || layout === CARD_LAYOUT.VERTICAL;
|
|
59
59
|
const { isHovered, anchorElementProps } = useHover();
|
|
60
60
|
const [activeBackground, setActiveBackground] = useState(isHovered ? COLOR.ND_SKY_BLUE : COLOR.BACKGROUND);
|
|
@@ -65,18 +65,23 @@ export const Card = ({ size, displayDate, headline, image, layout, onClick, rais
|
|
|
65
65
|
const typography = size === CARD_SIZE.SM
|
|
66
66
|
? TYPOGRAPHY_TYPE.HEADLINE_SMALL
|
|
67
67
|
: TYPOGRAPHY_TYPE.HEADLINE_MEDIUM;
|
|
68
|
-
return (_jsxs(Group, Object.assign({}, anchorElementProps, { type: GROUP_TYPE.GROUP, role: onClick ? 'button' : 'group', onClick: onClick, onKeyDown: (e) => {
|
|
68
|
+
return (_jsxs(Group, Object.assign({}, anchorElementProps, { type: headline || heading ? GROUP_TYPE.REGION : GROUP_TYPE.GROUP, role: onClick ? 'button' : 'group', onClick: onClick, onKeyDown: (e) => {
|
|
69
69
|
if (onClick && e.key === KEY_CODES.ENTER) {
|
|
70
70
|
onClick();
|
|
71
71
|
}
|
|
72
|
-
}, tabIndex: onClick ? 0 : undefined, sx: Object.assign({ boxShadow: raised ? theme.boxShadow.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
}, tabIndex: onClick ? 0 : undefined, sx: Object.assign({ boxShadow: raised || heading ? theme.boxShadow.NORMAL : undefined, width: !isVertical && '100%', borderBottom: 'solid 2px', borderColor: COLOR.TRANSPARENT, cursor: onClick ? 'pointer' : undefined, display: 'flex', flexDirection: layout === CARD_LAYOUT.HORIZONTAL ? 'row' : 'column', alignItems: 'flex-start', ':hover,:focus': onClick
|
|
73
|
+
? {
|
|
74
|
+
transform: 'scale(1.01)',
|
|
75
|
+
borderColor: COLOR.ND_SKY_BLUE_DARK,
|
|
76
|
+
backgroundColor: COLOR.ND_SKY_BLUE,
|
|
77
|
+
}
|
|
78
|
+
: {} }, sx) }, { children: [image && (_jsx("img", { src: image, style: {
|
|
77
79
|
width: isVertical ? '100%' : 'auto',
|
|
78
80
|
height: isVertical ? 'auto' : '100%',
|
|
79
|
-
} })), displayDate && _jsx(DateDisplay, { date: displayDate }),
|
|
81
|
+
} })), displayDate && _jsx(DateDisplay, { date: displayDate }), heading && (_jsxs(Row, Object.assign({ sx: Object.assign({ bg: COLOR.PRIMARY, color: COLOR.WHITE, width: '100%', px: contentPaddingX, py: 3, justifyContent: 'space-between', alignItems: 'center' }, headingStyles) }, { children: [_jsxs(Row, { children: [headingIcon && (_jsx(Icon, { icon: headingIcon, size: FONT_SIZE.LG, color: COLOR.WHITE, sx: { mr: 2 } })), _jsx(Heading, Object.assign({ size: HEADING_SIZE.SM, sx: {
|
|
82
|
+
color: COLOR.WHITE,
|
|
83
|
+
whiteSpace: 'nowrap',
|
|
84
|
+
} }, { children: heading }))] }), _jsx(Row, { children: headingAction && headingAction })] }))), _jsx(Row, Object.assign({ sx: { px: contentPaddingX, py: contentPaddingY } }, { children: _jsxs(Column, Object.assign({ justify: "center" }, { children: [headline && (_jsx(Heading, Object.assign({ typography: typography, sx: { textAlign: 'justify' } }, { children: truncateHeadlineAfter ? (_jsx(ReadMore, Object.assign({ lines: truncateHeadlineAfter, typography: typography, sx: { bg: activeBackground } }, { children: headline }))) : (headline) }))), children && (_jsx(Box, Object.assign({ sx: { mt: headline && !heading ? 2 : 0 } }, { children: typeof children === 'function'
|
|
80
85
|
? children({ isHovered, activeBackground })
|
|
81
86
|
: children })))] })) }))] })));
|
|
82
87
|
};
|
|
@@ -20,5 +20,5 @@ import { FONT_SIZE } from '../../../theme/typography';
|
|
|
20
20
|
export const DEFAULT_MESSAGE = 'No results found.';
|
|
21
21
|
export const EmptyState = (_a) => {
|
|
22
22
|
var { icon, message, sx } = _a, rest = __rest(_a, ["icon", "message", "sx"]);
|
|
23
|
-
return (_jsxs(Column, Object.assign({ sx: Object.assign(Object.assign({}, sx), { width: '100%', alignItems: 'center', justifyContent: 'center', mt: 5 }) }, rest, { children: [_jsx(Row, { children: _jsx(Icon, { icon: icon || SearchOffIcon, size: FONT_SIZE.XL, color: COLOR.
|
|
23
|
+
return (_jsxs(Column, Object.assign({ sx: Object.assign(Object.assign({}, sx), { width: '100%', alignItems: 'center', justifyContent: 'center', mt: 5 }) }, rest, { children: [_jsx(Row, { children: _jsx(Icon, { icon: icon || SearchOffIcon, size: FONT_SIZE.XL, color: COLOR.GRAY }) }), _jsx(Row, Object.assign({ sx: { mt: 1 } }, { children: _jsx(Paragraph, Object.assign({ sx: { color: COLOR.GRAY }, size: PARAGRAPH_SIZE.LG }, { children: message || DEFAULT_MESSAGE })) }))] })));
|
|
24
24
|
};
|
|
@@ -28,7 +28,7 @@ export const NavMenu = (props) => {
|
|
|
28
28
|
justifyContent: 'center',
|
|
29
29
|
p: 3,
|
|
30
30
|
border: 'solid 1px',
|
|
31
|
-
borderColor: COLOR.
|
|
31
|
+
borderColor: COLOR.EXTRA_LIGHT_GRAY,
|
|
32
32
|
borderRadius: '4px',
|
|
33
33
|
} }, { children: [_jsx(Column, { sx: { flexGrow: 1 } }), submenu.items.map((submenuItem) => {
|
|
34
34
|
if (!(submenuItem.action.type === MENU_ACTION_TYPE.SUBMENU)) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ArrowLink } from '.';
|
|
3
|
+
import { Column } from '../layout/Column';
|
|
4
|
+
import { Box } from '../layout/Box';
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'Elements/ArrowLink',
|
|
7
|
+
component: ArrowLink,
|
|
8
|
+
};
|
|
9
|
+
export default meta;
|
|
10
|
+
export const Default = {
|
|
11
|
+
render: () => (_jsx(Column, { children: _jsx(Box, { children: _jsx(ArrowLink, Object.assign({ to: "/" }, { children: "Click Me" })) }) })),
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { render } from '../../../utils/test';
|
|
3
|
+
import { ArrowLink } from '.';
|
|
4
|
+
import { DefaultLink } from '../../providers/componentConfig';
|
|
5
|
+
const CUSTOM_INTERNAL_TEST_ID = 'internal-link-test-id';
|
|
6
|
+
const CUSTOM_EXTERNAL_TEST_ID = 'external-link-test-id';
|
|
7
|
+
const CustomInternalLink = (props) => {
|
|
8
|
+
return _jsx(DefaultLink, Object.assign({ "data-testid": CUSTOM_INTERNAL_TEST_ID }, props));
|
|
9
|
+
};
|
|
10
|
+
const CustomExternalLink = (props) => {
|
|
11
|
+
return _jsx(DefaultLink, Object.assign({ "data-testid": CUSTOM_EXTERNAL_TEST_ID }, props));
|
|
12
|
+
};
|
|
13
|
+
describe('ArrowLink', () => {
|
|
14
|
+
it('renders default external link component without throwing', () => {
|
|
15
|
+
const { getByRole } = render(_jsx(ArrowLink, Object.assign({ to: "https://google.com" }, { children: "Foo" })));
|
|
16
|
+
expect(getByRole('link')).toBeInTheDocument();
|
|
17
|
+
});
|
|
18
|
+
it('renders default internal link component without throwing', () => {
|
|
19
|
+
const { getByRole } = render(_jsx(ArrowLink, Object.assign({ to: "/test/path" }, { children: "Foo" })));
|
|
20
|
+
expect(getByRole('link')).toBeInTheDocument();
|
|
21
|
+
});
|
|
22
|
+
it('passes styles to custom component', () => {
|
|
23
|
+
const { getByTestId } = render(_jsxs(_Fragment, { children: [_jsx(ArrowLink, Object.assign({ to: "https://google.com", sx: { mt: 1 } }, { children: "Foo" })), _jsx(ArrowLink, Object.assign({ to: "/test/route", sx: { mt: 1 } }, { children: "Foo" }))] }), {
|
|
24
|
+
components: {
|
|
25
|
+
link: {
|
|
26
|
+
externalLinkComponent: CustomExternalLink,
|
|
27
|
+
internalLinkComponent: CustomInternalLink,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
expect(getByTestId(CUSTOM_EXTERNAL_TEST_ID)).toHaveStyle(`margin-top: 0.25rem`);
|
|
32
|
+
expect(getByTestId(CUSTOM_INTERNAL_TEST_ID)).toHaveStyle(`margin-top: 0.25rem`);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/** @jsxImportSource theme-ui */
|
|
3
|
+
import { StyledElementProps } from '../../../theme';
|
|
4
|
+
type ArrowLinkProps = StyledElementProps<HTMLLinkElement, {
|
|
5
|
+
to: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const ArrowLink: React.FC<ArrowLinkProps>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
13
|
+
import { COLOR } from '../../../theme/colors';
|
|
14
|
+
import { Link } from '../Link';
|
|
15
|
+
export const ArrowLink = (_a) => {
|
|
16
|
+
var { to, children, sx } = _a, rest = __rest(_a, ["to", "children", "sx"]);
|
|
17
|
+
return (_jsxs(Link, Object.assign({ to: to }, rest, { sx: Object.assign({ display: 'inline-flex', whiteSpace: 'nowrap', padding: 0, flexGrow: 0, position: 'relative', boxSizing: 'border-box', bg: COLOR.WHITE, color: COLOR.PRIMARY, ':hover': {
|
|
18
|
+
transform: 'scale(1.02)',
|
|
19
|
+
bg: COLOR.EXTRA_EXTRA_LIGHT_GRAY,
|
|
20
|
+
}, ':hover>svg': {
|
|
21
|
+
fill: COLOR.EXTRA_EXTRA_LIGHT_GRAY,
|
|
22
|
+
}, '>svg': {
|
|
23
|
+
fill: COLOR.WHITE,
|
|
24
|
+
} }, sx) }, { children: [_jsx("div", Object.assign({ sx: {
|
|
25
|
+
position: 'relative',
|
|
26
|
+
border: '1px solid #a7a7a7',
|
|
27
|
+
'border-width': '1px 0 2px 1px',
|
|
28
|
+
boxSizing: 'border-box',
|
|
29
|
+
padding: '0.125rem 1.5rem 0.125rem 0.5rem',
|
|
30
|
+
height: '100%',
|
|
31
|
+
flex: '1 1 auto',
|
|
32
|
+
} }, { children: children })), _jsxs("svg", Object.assign({ viewBox: "0 0 16 1", preserveAspectRatio: "none", sx: {
|
|
33
|
+
width: '16px',
|
|
34
|
+
right: '-16px',
|
|
35
|
+
top: '0px',
|
|
36
|
+
position: 'absolute',
|
|
37
|
+
height: '100%',
|
|
38
|
+
} }, { children: [_jsx("path", { d: "M0,0 0,0 16,0.5 0,1 0,1z" }), _jsx("line", { x1: "0", x2: "16", y1: "0", y2: "0.5", stroke: "#a7a7a7", strokeWidth: "0.05", strokeLinecap: "butt" }), _jsx("line", { x1: "0", x2: "16", y1: "1", y2: "0.5", stroke: "#a7a7a7", strokeWidth: "0.1", strokeLinecap: "butt" })] }))] })));
|
|
39
|
+
};
|
|
@@ -5,6 +5,7 @@ export default meta;
|
|
|
5
5
|
type Story = StoryObj<typeof Button>;
|
|
6
6
|
export declare const Default: Story;
|
|
7
7
|
export declare const CustomColor: Story;
|
|
8
|
+
export declare const Link: Story;
|
|
8
9
|
export declare const OutlineButton: Story;
|
|
9
10
|
export declare const TextButton: Story;
|
|
10
11
|
export declare const IconButton: Story;
|
|
@@ -2,12 +2,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import SearchIcon from '@mui/icons-material/Search';
|
|
3
3
|
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
|
|
4
4
|
import SettingsIcon from '@mui/icons-material/Settings';
|
|
5
|
-
import { BUTTON_SIZE, BUTTON_TYPE, Button } from '.';
|
|
5
|
+
import { BUTTON_SIZE, BUTTON_TYPE, Button, LinkButton } from '.';
|
|
6
6
|
import { GROUP_TYPE, Group } from '../Group';
|
|
7
7
|
import { HEADING_SIZE, Heading } from '../text/Heading';
|
|
8
8
|
import { Column } from '../layout/Column';
|
|
9
|
-
import { COLOR } from '../../../theme/colors';
|
|
10
9
|
import { Row } from '../layout/Row';
|
|
10
|
+
import { Paragraph } from '../text/Paragraph';
|
|
11
|
+
import { COLOR } from '../../../theme/colors';
|
|
11
12
|
const meta = {
|
|
12
13
|
title: 'Elements/Button',
|
|
13
14
|
component: Button,
|
|
@@ -26,8 +27,16 @@ export const Default = {
|
|
|
26
27
|
children: 'Click Me',
|
|
27
28
|
},
|
|
28
29
|
};
|
|
30
|
+
const facebookBlue = '#4267B2';
|
|
29
31
|
export const CustomColor = {
|
|
30
|
-
render: (args) => (
|
|
32
|
+
render: (args) => (_jsxs(Column, { children: [_jsx(Paragraph, { children: "Use customColor prop for colors not in theme" }), _jsx(Row, { children: _jsx(Button, Object.assign({}, args, { customColor: facebookBlue, textColor: COLOR.WHITE, sx: { mt: 1 } })) })] })),
|
|
33
|
+
args: {
|
|
34
|
+
type: BUTTON_TYPE.DEFAULT,
|
|
35
|
+
children: 'Click Me',
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
export const Link = {
|
|
39
|
+
render: (args) => (_jsx(Column, { children: sizes.map((size) => (_jsxs(Group, Object.assign({ type: GROUP_TYPE.REGION }, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD }, { children: size.label })), _jsx(LinkButton, Object.assign({}, args, { sx: { mt: 1 } }))] })))) })),
|
|
31
40
|
args: {
|
|
32
41
|
type: BUTTON_TYPE.DEFAULT,
|
|
33
42
|
children: 'Click Me',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** @jsxImportSource theme-ui */
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { StyledElementProps } from '../../../theme';
|
|
3
4
|
import { COLOR } from '../../../theme/colors';
|
|
4
5
|
export declare enum BUTTON_SIZE {
|
|
5
6
|
SM = "sm",
|
|
@@ -11,13 +12,28 @@ export declare enum BUTTON_TYPE {
|
|
|
11
12
|
TEXT = "text",
|
|
12
13
|
OUTLINE = "outline"
|
|
13
14
|
}
|
|
15
|
+
type ButtonProps = StyledElementProps<HTMLButtonElement, {
|
|
16
|
+
size?: BUTTON_SIZE;
|
|
17
|
+
type?: BUTTON_TYPE;
|
|
18
|
+
color?: COLOR;
|
|
19
|
+
textColor?: COLOR;
|
|
20
|
+
customColor?: string;
|
|
21
|
+
primaryIcon?: React.FC<any>;
|
|
22
|
+
leftIcon?: React.FC<any>;
|
|
23
|
+
rightIcon?: React.FC<any>;
|
|
24
|
+
accessibleLabel?: string;
|
|
25
|
+
loading?: boolean;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
}>;
|
|
14
28
|
export declare const Button: React.ForwardRefExoticComponent<{
|
|
15
29
|
sx?: import("../../../theme").StylesProp | undefined;
|
|
16
30
|
children?: React.ReactNode;
|
|
17
|
-
} & Omit<React.HTMLAttributes<HTMLButtonElement>, "children"> & {
|
|
31
|
+
} & Omit<React.HTMLAttributes<HTMLButtonElement>, "children" | "onChange"> & {
|
|
18
32
|
size?: BUTTON_SIZE | undefined;
|
|
19
33
|
type?: BUTTON_TYPE | undefined;
|
|
20
34
|
color?: COLOR | undefined;
|
|
35
|
+
textColor?: COLOR | undefined;
|
|
36
|
+
customColor?: string | undefined;
|
|
21
37
|
primaryIcon?: React.FC<any> | undefined;
|
|
22
38
|
leftIcon?: React.FC<any> | undefined;
|
|
23
39
|
rightIcon?: React.FC<any> | undefined;
|
|
@@ -25,3 +41,6 @@ export declare const Button: React.ForwardRefExoticComponent<{
|
|
|
25
41
|
loading?: boolean | undefined;
|
|
26
42
|
disabled?: boolean | undefined;
|
|
27
43
|
} & React.RefAttributes<HTMLButtonElement>>;
|
|
44
|
+
type LinkButtonProps = Omit<ButtonProps, 'type' | 'color' | 'textColor'>;
|
|
45
|
+
export declare const LinkButton: React.FC<LinkButtonProps>;
|
|
46
|
+
export {};
|
|
@@ -11,9 +11,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
13
13
|
/** @jsxImportSource theme-ui */
|
|
14
|
-
import React
|
|
14
|
+
import React from 'react';
|
|
15
15
|
import { useTheme } from '../../../theme';
|
|
16
|
-
import { COLOR
|
|
16
|
+
import { COLOR } from '../../../theme/colors';
|
|
17
17
|
import { TYPOGRAPHY_TYPE, getIconSize, getTypographyStyles, } from '../../../theme/typography';
|
|
18
18
|
import { Icon } from '../Icon';
|
|
19
19
|
import { useEnvironment } from '../../providers/env';
|
|
@@ -52,17 +52,14 @@ export var BUTTON_TYPE;
|
|
|
52
52
|
// ARROW
|
|
53
53
|
})(BUTTON_TYPE || (BUTTON_TYPE = {}));
|
|
54
54
|
export const Button = React.forwardRef((_a, ref) => {
|
|
55
|
-
var { size: sizeParam, type: typeParam, color, primaryIcon, leftIcon, rightIcon, disabled: disabledParam, children, sx, loading } = _a, rest = __rest(_a, ["size", "type", "color", "primaryIcon", "leftIcon", "rightIcon", "disabled", "children", "sx", "loading"]);
|
|
55
|
+
var { size: sizeParam, type: typeParam, color, customColor, textColor: textColorParam, primaryIcon, leftIcon, rightIcon, disabled: disabledParam, children, sx, loading } = _a, rest = __rest(_a, ["size", "type", "color", "customColor", "textColor", "primaryIcon", "leftIcon", "rightIcon", "disabled", "children", "sx", "loading"]);
|
|
56
56
|
const disabled = disabledParam || loading;
|
|
57
57
|
const theme = useTheme();
|
|
58
|
-
const [hover, setHover] = useState(false);
|
|
59
58
|
const { flagInDevelopment } = useEnvironment();
|
|
60
59
|
let bg = COLOR.PRIMARY;
|
|
61
|
-
let hoverBg = COLOR.PRIMARY_HIGHLIGHT;
|
|
62
|
-
let textColor = COLOR.TEXT;
|
|
63
|
-
let hoverTextColor = undefined;
|
|
64
60
|
let borderColor = COLOR.TRANSPARENT;
|
|
65
61
|
let cursor = 'pointer';
|
|
62
|
+
let textColor = COLOR.BACKGROUND;
|
|
66
63
|
let hoverShadow = theme.boxShadow.NORMAL;
|
|
67
64
|
let hoverDecoration = undefined;
|
|
68
65
|
let hoverTransform = 'scale(1.03)';
|
|
@@ -73,7 +70,6 @@ export const Button = React.forwardRef((_a, ref) => {
|
|
|
73
70
|
const paddingX = isIconButton || isTextButton ? 0 : defaultPaddingX[size];
|
|
74
71
|
const height = isTextButton ? undefined : defaultHeight[size];
|
|
75
72
|
const width = primaryIcon ? height : undefined;
|
|
76
|
-
// const height = width;
|
|
77
73
|
if (isIconButton && !rest['aria-label']) {
|
|
78
74
|
flagInDevelopment('Icon buttons should include aria-label prop for accessibility');
|
|
79
75
|
}
|
|
@@ -81,53 +77,37 @@ export const Button = React.forwardRef((_a, ref) => {
|
|
|
81
77
|
hoverTransform = 'scale(1.15)';
|
|
82
78
|
}
|
|
83
79
|
if (type === BUTTON_TYPE.DEFAULT) {
|
|
84
|
-
bg = color || COLOR.
|
|
85
|
-
|
|
86
|
-
bg === COLOR.PRIMARY
|
|
87
|
-
? COLOR.PRIMARY_HIGHLIGHT
|
|
88
|
-
: bg === COLOR.SECONDARY
|
|
89
|
-
? COLOR.SECONDARY_HIGHLIGHT
|
|
90
|
-
: bg;
|
|
91
|
-
textColor =
|
|
92
|
-
bg === COLOR.PRIMARY
|
|
93
|
-
? COLOR.TEXT_ON_PRIMARY
|
|
94
|
-
: bg === COLOR.SECONDARY
|
|
95
|
-
? COLOR.TEXT_ON_SECONDARY
|
|
96
|
-
: COLOR.TEXT;
|
|
97
|
-
hoverTextColor = textColor;
|
|
80
|
+
bg = color || COLOR.SECONDARY;
|
|
81
|
+
textColor = COLOR.BLACK;
|
|
98
82
|
}
|
|
99
83
|
if (type === BUTTON_TYPE.TEXT) {
|
|
100
84
|
bg = COLOR.TRANSPARENT;
|
|
101
|
-
hoverBg = bg;
|
|
102
85
|
textColor = color || COLOR.PRIMARY;
|
|
103
|
-
hoverTextColor = textColor;
|
|
104
86
|
hoverShadow = undefined;
|
|
105
87
|
hoverDecoration = 'underline';
|
|
106
88
|
}
|
|
107
89
|
if (type === BUTTON_TYPE.OUTLINE) {
|
|
108
90
|
bg = COLOR.BACKGROUND;
|
|
109
|
-
hoverBg = COLOR.BACKGROUND;
|
|
110
91
|
textColor = color || COLOR.PRIMARY;
|
|
111
|
-
hoverTextColor = textColor;
|
|
112
92
|
borderColor = textColor;
|
|
113
93
|
}
|
|
94
|
+
if (textColorParam) {
|
|
95
|
+
textColor = textColorParam;
|
|
96
|
+
}
|
|
114
97
|
if (disabled) {
|
|
115
98
|
cursor = 'not-allowed';
|
|
116
|
-
if (bg === COLOR.PRIMARY) {
|
|
117
|
-
bg = hoverBg = COLOR.LIGHT_GRAY;
|
|
118
|
-
}
|
|
119
99
|
if (bg === COLOR.BACKGROUND || bg === COLOR.TRANSPARENT) {
|
|
120
|
-
textColor = COLOR.
|
|
100
|
+
textColor = COLOR.GRAY;
|
|
121
101
|
}
|
|
122
102
|
else {
|
|
123
|
-
bg = COLOR.
|
|
103
|
+
bg = COLOR.GRAY;
|
|
124
104
|
}
|
|
125
105
|
}
|
|
126
106
|
const typography = typographyMap[size];
|
|
127
107
|
const typographyStyles = getTypographyStyles(typography);
|
|
128
108
|
let body = children;
|
|
129
109
|
if (primaryIcon) {
|
|
130
|
-
body = (_jsx(Icon, { icon: primaryIcon, size: getIconSize(typographyStyles.fontSize), color:
|
|
110
|
+
body = (_jsx(Icon, { icon: primaryIcon, size: getIconSize(typographyStyles.fontSize), color: textColor }));
|
|
131
111
|
}
|
|
132
112
|
if (loading) {
|
|
133
113
|
body = (_jsxs("div", Object.assign({ sx: {
|
|
@@ -137,33 +117,24 @@ export const Button = React.forwardRef((_a, ref) => {
|
|
|
137
117
|
justifyContent: 'center',
|
|
138
118
|
} }, { children: [_jsx(Spinner, { size: SPINNER_SIZE.SM, color: textColor, sx: { position: 'absolute' } }), _jsx("div", Object.assign({ sx: { visibility: 'hidden' } }, { children: body }))] })));
|
|
139
119
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
textDecoration: hoverDecoration,
|
|
151
|
-
}
|
|
152
|
-
: undefined, ':focus': !disabled
|
|
153
|
-
? {
|
|
154
|
-
bg: hoverBg,
|
|
155
|
-
color: hoverTextColor,
|
|
156
|
-
boxShadow: hoverShadow,
|
|
157
|
-
cursor: 'pointer',
|
|
158
|
-
transform: hoverTransform,
|
|
159
|
-
textDecoration: hoverDecoration,
|
|
160
|
-
}
|
|
161
|
-
: undefined }, typographyStyles), sx) }, rest, { children: [leftIcon && (_jsx(Icon, { icon: leftIcon, size: typographyStyles.fontSize, sx: { mr: iconMargin[size] }, color: hover ? hoverTextColor : textColor })), _jsx("div", Object.assign({ css: {
|
|
120
|
+
const hoverStyles = !disabled
|
|
121
|
+
? {
|
|
122
|
+
boxShadow: hoverShadow,
|
|
123
|
+
transform: hoverTransform,
|
|
124
|
+
textDecoration: hoverDecoration,
|
|
125
|
+
}
|
|
126
|
+
: undefined;
|
|
127
|
+
return (_jsxs("button", Object.assign({ ref: ref, tabIndex: disabled ? -1 : 0, disabled: disabled, css: {
|
|
128
|
+
backgroundColor: customColor,
|
|
129
|
+
}, sx: Object.assign(Object.assign({ cursor, bg: customColor ? undefined : bg, color: textColor, px: paddingX, width: width, height: height, border: 'solid 1px', borderRadius: '4px', borderColor, display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'center', ':hover': hoverStyles, ':focus': hoverStyles }, typographyStyles), sx) }, rest, { children: [leftIcon && (_jsx(Icon, { icon: leftIcon, size: typographyStyles.fontSize, sx: { mr: iconMargin[size] }, color: textColor })), _jsx("div", Object.assign({ css: {
|
|
162
130
|
flexGrow: 1,
|
|
163
131
|
justifyContent: 'flex-start',
|
|
164
132
|
textOverflow: 'ellipsis',
|
|
165
133
|
whiteSpace: 'nowrap',
|
|
166
134
|
overflow: 'hidden',
|
|
167
135
|
textAlign: 'start',
|
|
168
|
-
} }, { children: body })), rightIcon && (_jsx(Icon, { icon: rightIcon, size: typographyStyles.fontSize, sx: { ml: iconMargin[size] }, color:
|
|
136
|
+
} }, { children: body })), rightIcon && (_jsx(Icon, { icon: rightIcon, size: typographyStyles.fontSize, sx: { ml: iconMargin[size] }, color: textColor }))] })));
|
|
169
137
|
});
|
|
138
|
+
export const LinkButton = (props) => {
|
|
139
|
+
return (_jsx(Button, Object.assign({}, props, { color: COLOR.ND_BLUE_BRIGHT, textColor: COLOR.WHITE })));
|
|
140
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { AutoComplete } from '.';
|
|
3
|
+
import { Paragraph, PARAGRAPH_SIZE } from '../../text/Paragraph';
|
|
4
|
+
import { HEADING_SIZE, Heading } from '../../text/Heading';
|
|
5
|
+
import { Column } from '../../layout/Column';
|
|
6
|
+
import { Row } from '../../layout/Row';
|
|
7
|
+
const options = [
|
|
8
|
+
{
|
|
9
|
+
label: 'Cucumber',
|
|
10
|
+
value: 'Cucumber',
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
label: 'Egg Plant',
|
|
14
|
+
value: 'Egg Plant',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
label: 'Napa',
|
|
18
|
+
value: 'Napa',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
label: 'Cabbage',
|
|
22
|
+
value: 'Cabbage',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
label: 'Broccoli',
|
|
26
|
+
value: 'Broccoli',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
label: 'Radish',
|
|
30
|
+
value: 'Radish',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: 'Cauliflower',
|
|
34
|
+
value: 'Cauliflower',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: 'Beet',
|
|
38
|
+
value: 'Beet',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
label: 'Tomato',
|
|
42
|
+
value: 'Tomato',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
label: 'Zuchinni',
|
|
46
|
+
value: 'Zuchinni',
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
function onSelect() {
|
|
50
|
+
return console.log('clicked');
|
|
51
|
+
}
|
|
52
|
+
const meta = {
|
|
53
|
+
title: 'Elements/Fields/AutoComplete',
|
|
54
|
+
component: AutoComplete,
|
|
55
|
+
tags: ['autodocs'],
|
|
56
|
+
};
|
|
57
|
+
export default meta;
|
|
58
|
+
export const Default = {
|
|
59
|
+
render: () => (_jsx(_Fragment, { children: _jsx(Row, Object.assign({ justify: "space-between" }, { children: _jsxs(Column, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.LG }, { children: "Vegetables" })), _jsx("br", {}), _jsx(AutoComplete, { options: options, value: "cucumber", onSelect: onSelect }), _jsx("br", {}), _jsx(Paragraph, Object.assign({ size: PARAGRAPH_SIZE.LG }, { children: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ultrices venenatis purus at porta. Etiam congue sapien leo, sed malesuada justo commodo in. Nunc consequat, massa non cursus posuere, magna eros lacinia lectus, eget lobortis mi erat ut justo. Maecenas nisi mi, mollis sed ornare vitae, pharetra sed augue. Curabitur mollis orci risus, sed imperdiet nisi aliquet et. Ut non elit nec magna rhoncus maximus sit amet ut dui. Mauris sit amet eleifend lectus. Aliquam consectetur posuere libero eu ultricies. Etiam rutrum non orci nec vulputate. Sed vel accumsan diam. Cras aliquet eros eros, sit amet pharetra eros tincidunt ut. Vestibulum est erat, eleifend dapibus eros vel, elementum vehicula risus. Etiam blandit condimentum sodales. Donec non libero in orci aliquam egestas fringilla eget purus. Suspendisse pellentesque at ligula ut accumsan." }))] }) })) })),
|
|
60
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface Option {
|
|
2
|
+
label: string;
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
interface AutoCompleteProps {
|
|
6
|
+
value: string;
|
|
7
|
+
options: Option[];
|
|
8
|
+
onSelect: (option: string) => any;
|
|
9
|
+
}
|
|
10
|
+
export declare const AutoComplete: ({ value, options, onSelect, }: AutoCompleteProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default AutoComplete;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { COLOR } from '../../../../theme/colors';
|
|
4
|
+
import { ListBox } from '../../ListBox';
|
|
5
|
+
import { TextInput } from '../../Fields/TextInput';
|
|
6
|
+
export const AutoComplete = ({ value, options, onSelect, }) => {
|
|
7
|
+
const [inputValue, setInputValue] = useState(value);
|
|
8
|
+
const [filteredOptions, setFilteredOptions] = useState(options);
|
|
9
|
+
const [showOptions, setShowOptions] = useState(false);
|
|
10
|
+
const handleChange = (value) => {
|
|
11
|
+
setInputValue(value);
|
|
12
|
+
const newFilteredOptions = options.filter((option) => option.label.toLowerCase().includes(value.toLowerCase()));
|
|
13
|
+
setFilteredOptions(newFilteredOptions);
|
|
14
|
+
setShowOptions(true);
|
|
15
|
+
};
|
|
16
|
+
const handleSelect = (selectedOption) => {
|
|
17
|
+
setShowOptions(false);
|
|
18
|
+
setInputValue(selectedOption.label);
|
|
19
|
+
onSelect(selectedOption.value);
|
|
20
|
+
};
|
|
21
|
+
return (_jsxs("div", { children: [_jsx(TextInput, { value: inputValue, onChange: handleChange }), showOptions && (_jsx(ListBox, { options: filteredOptions, selectOption: handleSelect, sx: {
|
|
22
|
+
bg: COLOR.PRIMARY,
|
|
23
|
+
marginTop: 2,
|
|
24
|
+
} }))] }));
|
|
25
|
+
};
|
|
26
|
+
export default AutoComplete;
|
|
@@ -126,12 +126,12 @@ export function Select({ size: sizeParam, placeholder, leftIcon, value, onSelect
|
|
|
126
126
|
else {
|
|
127
127
|
close();
|
|
128
128
|
}
|
|
129
|
-
}, sx: Object.assign(Object.assign({ height, width: DEFAULT_WIDTH, border: 'solid 1px', borderColor: COLOR.
|
|
129
|
+
}, sx: Object.assign(Object.assign({ height, width: DEFAULT_WIDTH, border: 'solid 1px', borderColor: COLOR.GRAY, borderRadius: '4px', flexDirection: 'row', alignItems: 'center', position: 'relative', ':hover': {
|
|
130
130
|
boxShadow: theme.boxShadow.NORMAL,
|
|
131
131
|
}, ':focus': {
|
|
132
132
|
boxShadow: theme.boxShadow.NORMAL,
|
|
133
|
-
} }, typographyStyles), sx), leftIcon: leftIcon, rightIcon: ArrowDropDownIcon }, { children: currentOption ? renderOptionLabel(currentOption) : placeholder })), isOpen && (_jsx(ListBox, { id: listboxId, options: options, selected: value, focused: stagedOptionValue, selectOption: (
|
|
134
|
-
onSelectOption && onSelectOption(value);
|
|
133
|
+
} }, typographyStyles), sx), leftIcon: leftIcon, rightIcon: ArrowDropDownIcon }, { children: currentOption ? renderOptionLabel(currentOption) : placeholder })), isOpen && (_jsx(ListBox, { id: listboxId, options: options, selected: value, focused: stagedOptionValue, selectOption: (option) => {
|
|
134
|
+
onSelectOption && onSelectOption(option.value);
|
|
135
135
|
close();
|
|
136
136
|
}, ref: refs.setFloating, renderOption: renderOption, style: Object.assign(Object.assign({ minWidth: dropdownMinWidth }, floatingStyles), { zIndex: 1 }) }))] }));
|
|
137
137
|
}
|
|
@@ -17,7 +17,7 @@ export type TextInputProps = StyledElementProps<HTMLInputElement, {
|
|
|
17
17
|
export declare const TextInput: React.ForwardRefExoticComponent<{
|
|
18
18
|
sx?: import("../../../../theme").StylesProp | undefined;
|
|
19
19
|
children?: string | undefined;
|
|
20
|
-
} & Omit<React.HTMLAttributes<HTMLInputElement>, "children"> & {
|
|
20
|
+
} & Omit<React.HTMLAttributes<HTMLInputElement>, "children" | "onChange"> & {
|
|
21
21
|
size?: INPUT_SIZE | undefined;
|
|
22
22
|
leftIcon?: React.FC<any> | undefined;
|
|
23
23
|
inline?: boolean | undefined;
|
|
@@ -47,7 +47,7 @@ export const TextInput = React.forwardRef((_a, ref) => {
|
|
|
47
47
|
const typography = typographyMap[size];
|
|
48
48
|
const typographyStyles = getTypographyStyles(typography);
|
|
49
49
|
return (_jsxs("div", Object.assign({ ref: ref, onClick: onClick, sx: Object.assign(Object.assign({ height,
|
|
50
|
-
display, px: paddingX, border: 'solid 1px', borderColor: COLOR.
|
|
50
|
+
display, px: paddingX, border: 'solid 1px', borderColor: COLOR.GRAY, borderRadius: '4px', flexDirection: 'row', alignItems: 'center', ':hover': {
|
|
51
51
|
boxShadow: theme.boxShadow.NORMAL,
|
|
52
52
|
}, ':focus': {
|
|
53
53
|
boxShadow: theme.boxShadow.NORMAL,
|
|
@@ -7,7 +7,7 @@ type ListBoxProps<Value extends Key, Option extends BasicOption<Value>> = Styled
|
|
|
7
7
|
renderOption?: RenderOption<Value, Option>;
|
|
8
8
|
selected?: Value;
|
|
9
9
|
focused?: Value;
|
|
10
|
-
selectOption?: (
|
|
10
|
+
selectOption?: (option: Option) => void;
|
|
11
11
|
onDownPress?: () => void;
|
|
12
12
|
onUpPress?: () => void;
|
|
13
13
|
onSelect?: () => void;
|
|
@@ -16,12 +16,12 @@ type ListBoxProps<Value extends Key, Option extends BasicOption<Value>> = Styled
|
|
|
16
16
|
export declare const ListBox: <Value extends React.Key = string, Option extends BasicOption<Value> = any>(props: {
|
|
17
17
|
sx?: import("../../../theme").StylesProp | undefined;
|
|
18
18
|
children?: React.ReactNode;
|
|
19
|
-
} & Omit<React.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
19
|
+
} & Omit<React.HTMLAttributes<HTMLDivElement>, "children" | "onChange"> & {
|
|
20
20
|
options: Option[];
|
|
21
21
|
renderOption?: RenderOption<Value, Option> | undefined;
|
|
22
22
|
selected?: Value | undefined;
|
|
23
23
|
focused?: Value | undefined;
|
|
24
|
-
selectOption?: ((
|
|
24
|
+
selectOption?: ((option: Option) => void) | undefined;
|
|
25
25
|
onDownPress?: (() => void) | undefined;
|
|
26
26
|
onUpPress?: (() => void) | undefined;
|
|
27
27
|
onSelect?: (() => void) | undefined;
|
|
@@ -21,10 +21,12 @@ function ListBoxInner(_a, ref) {
|
|
|
21
21
|
const typography = getTypographyStyles(TYPOGRAPHY_TYPE.PARAGRAPH_MEDIUM);
|
|
22
22
|
return (_jsx("div", Object.assign({ role: "listbox", ref: ref, sx: Object.assign(Object.assign({ border: 'solid 1px', borderRadius: '4px', borderColor: COLOR.LIGHT_GRAY, backgroundColor: COLOR.BACKGROUND, boxShadow: '0px 0px 8px 2px #dddddd' }, typography), sx), onKeyDown: (e) => {
|
|
23
23
|
console.log(e);
|
|
24
|
-
} }, rest, { children: options.map((option) => (_jsx("div", Object.assign({ id: getOptionId(option.value), "aria-selected": selected === option.value, role: "option", onClick: option.onClick, onMouseDown: () => selectOption && selectOption(option
|
|
24
|
+
} }, rest, { children: options.map((option) => (_jsx("div", Object.assign({ id: getOptionId(option.value), "aria-selected": selected === option.value, role: "option", onClick: option.onClick, onMouseDown: () => selectOption && selectOption(option), sx: {
|
|
25
25
|
px: 4,
|
|
26
26
|
py: 3,
|
|
27
|
-
backgroundColor: focused === option.value
|
|
27
|
+
backgroundColor: focused === option.value
|
|
28
|
+
? COLOR.EXTRA_EXTRA_LIGHT_GRAY
|
|
29
|
+
: COLOR.BACKGROUND,
|
|
28
30
|
cursor: 'pointer',
|
|
29
31
|
borderBottom: 'solid 1px',
|
|
30
32
|
borderBottomColor: COLOR.LIGHT_GRAY,
|
|
@@ -39,7 +41,7 @@ function ListBoxInner(_a, ref) {
|
|
|
39
41
|
borderTopLeftRadius: '4px',
|
|
40
42
|
},
|
|
41
43
|
':hover': {
|
|
42
|
-
backgroundColor: COLOR.
|
|
44
|
+
backgroundColor: COLOR.EXTRA_EXTRA_LIGHT_GRAY,
|
|
43
45
|
},
|
|
44
46
|
} }, { children: renderOption({
|
|
45
47
|
option,
|
|
@@ -12,7 +12,7 @@ export declare enum PILL_TYPE {
|
|
|
12
12
|
export declare const Pill: React.ForwardRefExoticComponent<{
|
|
13
13
|
sx?: import("../../../theme").StylesProp | undefined;
|
|
14
14
|
children?: React.ReactNode;
|
|
15
|
-
} & Omit<React.HTMLAttributes<HTMLButtonElement>, "children"> & {
|
|
15
|
+
} & Omit<React.HTMLAttributes<HTMLButtonElement>, "children" | "onChange"> & {
|
|
16
16
|
size?: PILL_SIZE | undefined;
|
|
17
17
|
type?: PILL_TYPE | undefined;
|
|
18
18
|
color?: COLOR | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ export { COLOR } from './theme/colors';
|
|
|
3
3
|
export { TYPOGRAPHY_TYPE, FONT, FONT_SIZE, FONT_WEIGHT, LINE_HEIGHT, } from './theme/typography';
|
|
4
4
|
export { GlobalStyles } from './theme/GlobalStyles';
|
|
5
5
|
export { Alert, Alerts } from './components/elements/Alerts';
|
|
6
|
+
export { ArrowLink } from './components/elements/ArrowLink';
|
|
6
7
|
export { BrandingBar } from './components/elements/BrandingBar';
|
|
7
|
-
export { Button, BUTTON_SIZE, BUTTON_TYPE } from './components/elements/Button';
|
|
8
|
+
export { Button, BUTTON_SIZE, BUTTON_TYPE, LinkButton, } from './components/elements/Button';
|
|
8
9
|
export { Heading, HEADING_SIZE } from './components/elements/text/Heading';
|
|
9
10
|
export { Label, LABEL_SIZE } from './components/elements/text/Label';
|
|
10
11
|
export { Paragraph, PARAGRAPH_SIZE } from './components/elements/text/Paragraph';
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,9 @@ export { COLOR } from './theme/colors';
|
|
|
3
3
|
export { TYPOGRAPHY_TYPE, FONT, FONT_SIZE, FONT_WEIGHT, LINE_HEIGHT, } from './theme/typography';
|
|
4
4
|
export { GlobalStyles } from './theme/GlobalStyles';
|
|
5
5
|
export { Alert, Alerts } from './components/elements/Alerts';
|
|
6
|
+
export { ArrowLink } from './components/elements/ArrowLink';
|
|
6
7
|
export { BrandingBar } from './components/elements/BrandingBar';
|
|
7
|
-
export { Button, BUTTON_SIZE, BUTTON_TYPE } from './components/elements/Button';
|
|
8
|
+
export { Button, BUTTON_SIZE, BUTTON_TYPE, LinkButton, } from './components/elements/Button';
|
|
8
9
|
export { Heading, HEADING_SIZE } from './components/elements/text/Heading';
|
|
9
10
|
export { Label, LABEL_SIZE } from './components/elements/text/Label';
|
|
10
11
|
export { Paragraph, PARAGRAPH_SIZE } from './components/elements/text/Paragraph';
|
|
@@ -16,12 +16,18 @@ const colors = [
|
|
|
16
16
|
{ color: COLOR.BACKGROUND, label: 'BACKGROUND' },
|
|
17
17
|
{ color: COLOR.PRIMARY, label: 'PRIMARY' },
|
|
18
18
|
{ color: COLOR.PRIMARY_HIGHLIGHT, label: 'PRIMARY_HIGHLIGHT' },
|
|
19
|
-
{ color: COLOR.
|
|
20
|
-
{ color: COLOR.
|
|
21
|
-
{ color: COLOR.
|
|
22
|
-
{ color: COLOR.
|
|
19
|
+
{ color: COLOR.GRAY, label: 'GRAY' },
|
|
20
|
+
{ color: COLOR.DARK_GRAY, label: 'DARK_GRAY' },
|
|
21
|
+
{ color: COLOR.LIGHT_GRAY, label: 'LIGHT GRAY' },
|
|
22
|
+
{ color: COLOR.EXTRA_LIGHT_GRAY, label: 'EXTRA_LIGHT_GRAY' },
|
|
23
|
+
{ color: COLOR.EXTRA_EXTRA_LIGHT_GRAY, label: 'EXTRA_EXTRA_LIGHT_GRAY' },
|
|
23
24
|
{ color: COLOR.ND_BLUE, label: 'ND_BLUE' },
|
|
25
|
+
{ color: COLOR.ND_BLUE_DARK, label: 'ND_BLUE_DARK' },
|
|
26
|
+
{ color: COLOR.ND_BLUE_LIGHT, label: 'ND_BLUE_LIGHT' },
|
|
27
|
+
{ color: COLOR.ND_BLUE_BRIGHT, label: 'ND_BLUE_BRIGHT' },
|
|
24
28
|
{ color: COLOR.ND_GOLD, label: 'ND_GOLD' },
|
|
29
|
+
{ color: COLOR.ND_GOLD_LIGHT, label: 'ND_GOLD_LIGHT' },
|
|
30
|
+
{ color: COLOR.ND_GOLD_DARK, label: 'ND_GOLD_DARK' },
|
|
25
31
|
{ color: COLOR.ND_METALLIC_GOLD, label: 'ND_METALLIC_GOLD' },
|
|
26
32
|
{ color: COLOR.ND_PROVOST_BLUE, label: 'ND_PROVOST_BLUE' },
|
|
27
33
|
{ color: COLOR.ND_SECONDARY_1, label: 'ND_SECONDARY_1' },
|
package/dist/theme/colors.d.ts
CHANGED
|
@@ -3,16 +3,25 @@ export declare enum COLOR {
|
|
|
3
3
|
BACKGROUND = "background",
|
|
4
4
|
TRANSPARENT = "transparent",
|
|
5
5
|
PRIMARY = "primary",
|
|
6
|
+
TEXT_ON_PRIMARY = "textOnPrimary",
|
|
6
7
|
PRIMARY_HIGHLIGHT = "primaryHighlight",
|
|
7
8
|
SECONDARY = "secondary",
|
|
8
|
-
SECONDARY_HIGHLIGHT = "secondaryHighlight",
|
|
9
|
-
TEXT_ON_PRIMARY = "textOnPrimary",
|
|
10
9
|
TEXT_ON_SECONDARY = "textOnSecondary",
|
|
10
|
+
SECONDARY_HIGHLIGHT = "secondaryHighlight",
|
|
11
|
+
WHITE = "white",
|
|
12
|
+
BLACK = "black",
|
|
13
|
+
DARK_GRAY = "darkGray",
|
|
14
|
+
GRAY = "gray",
|
|
11
15
|
LIGHT_GRAY = "lightGray",
|
|
12
|
-
|
|
16
|
+
EXTRA_LIGHT_GRAY = "extraLightGray",
|
|
17
|
+
EXTRA_EXTRA_LIGHT_GRAY = "extraExtraLightGray",
|
|
13
18
|
ND_BLUE = "ndBlue",
|
|
19
|
+
ND_BLUE_DARK = "ndBlueDark",
|
|
14
20
|
ND_BLUE_LIGHT = "ndBlueLight",
|
|
21
|
+
ND_BLUE_BRIGHT = "ndBlueBright",
|
|
15
22
|
ND_GOLD = "ndGold",
|
|
23
|
+
ND_GOLD_LIGHT = "ndGoldLight",
|
|
24
|
+
ND_GOLD_DARK = "ndGoldDark",
|
|
16
25
|
ND_SKY_BLUE = "ndSkyBlue",
|
|
17
26
|
ND_SKY_BLUE_DARK = "ndSkyBlueDark",
|
|
18
27
|
ND_METALLIC_GOLD = "ndMetallicGold",
|
package/dist/theme/colors.js
CHANGED
|
@@ -4,16 +4,25 @@ export var COLOR;
|
|
|
4
4
|
COLOR["BACKGROUND"] = "background";
|
|
5
5
|
COLOR["TRANSPARENT"] = "transparent";
|
|
6
6
|
COLOR["PRIMARY"] = "primary";
|
|
7
|
+
COLOR["TEXT_ON_PRIMARY"] = "textOnPrimary";
|
|
7
8
|
COLOR["PRIMARY_HIGHLIGHT"] = "primaryHighlight";
|
|
8
9
|
COLOR["SECONDARY"] = "secondary";
|
|
9
|
-
COLOR["SECONDARY_HIGHLIGHT"] = "secondaryHighlight";
|
|
10
|
-
COLOR["TEXT_ON_PRIMARY"] = "textOnPrimary";
|
|
11
10
|
COLOR["TEXT_ON_SECONDARY"] = "textOnSecondary";
|
|
11
|
+
COLOR["SECONDARY_HIGHLIGHT"] = "secondaryHighlight";
|
|
12
|
+
COLOR["WHITE"] = "white";
|
|
13
|
+
COLOR["BLACK"] = "black";
|
|
14
|
+
COLOR["DARK_GRAY"] = "darkGray";
|
|
15
|
+
COLOR["GRAY"] = "gray";
|
|
12
16
|
COLOR["LIGHT_GRAY"] = "lightGray";
|
|
13
|
-
COLOR["
|
|
17
|
+
COLOR["EXTRA_LIGHT_GRAY"] = "extraLightGray";
|
|
18
|
+
COLOR["EXTRA_EXTRA_LIGHT_GRAY"] = "extraExtraLightGray";
|
|
14
19
|
COLOR["ND_BLUE"] = "ndBlue";
|
|
20
|
+
COLOR["ND_BLUE_DARK"] = "ndBlueDark";
|
|
15
21
|
COLOR["ND_BLUE_LIGHT"] = "ndBlueLight";
|
|
22
|
+
COLOR["ND_BLUE_BRIGHT"] = "ndBlueBright";
|
|
16
23
|
COLOR["ND_GOLD"] = "ndGold";
|
|
24
|
+
COLOR["ND_GOLD_LIGHT"] = "ndGoldLight";
|
|
25
|
+
COLOR["ND_GOLD_DARK"] = "ndGoldDark";
|
|
17
26
|
COLOR["ND_SKY_BLUE"] = "ndSkyBlue";
|
|
18
27
|
COLOR["ND_SKY_BLUE_DARK"] = "ndSkyBlueDark";
|
|
19
28
|
COLOR["ND_METALLIC_GOLD"] = "ndMetallicGold";
|
|
@@ -38,20 +47,29 @@ export var COLOR;
|
|
|
38
47
|
COLOR["ALERT_WARNING_BORDER"] = "alertWarningBorder";
|
|
39
48
|
})(COLOR || (COLOR = {}));
|
|
40
49
|
export const colors = {
|
|
41
|
-
[COLOR.TEXT]: '#
|
|
50
|
+
[COLOR.TEXT]: '#333333',
|
|
42
51
|
[COLOR.BACKGROUND]: '#ffffff',
|
|
43
52
|
[COLOR.TRANSPARENT]: 'rgba(0,0,0,0)',
|
|
44
53
|
[COLOR.PRIMARY]: '#0c2340',
|
|
45
|
-
[COLOR.PRIMARY_HIGHLIGHT]: '#000d1d',
|
|
46
54
|
[COLOR.TEXT_ON_PRIMARY]: '#ffffff',
|
|
47
|
-
[COLOR.
|
|
55
|
+
[COLOR.PRIMARY_HIGHLIGHT]: '#000d1d',
|
|
56
|
+
[COLOR.SECONDARY]: '#d39f10',
|
|
48
57
|
[COLOR.SECONDARY_HIGHLIGHT]: '#ddcc70',
|
|
49
|
-
[COLOR.TEXT_ON_SECONDARY]: '#
|
|
50
|
-
[COLOR.
|
|
51
|
-
[COLOR.
|
|
58
|
+
[COLOR.TEXT_ON_SECONDARY]: '#040401',
|
|
59
|
+
[COLOR.WHITE]: '#ffffff',
|
|
60
|
+
[COLOR.BLACK]: '#000000',
|
|
61
|
+
[COLOR.DARK_GRAY]: '#333333',
|
|
62
|
+
[COLOR.GRAY]: '#555555',
|
|
63
|
+
[COLOR.LIGHT_GRAY]: '#d2d2d2',
|
|
64
|
+
[COLOR.EXTRA_LIGHT_GRAY]: '#e2e2e2',
|
|
65
|
+
[COLOR.EXTRA_EXTRA_LIGHT_GRAY]: '#f2f2f2',
|
|
66
|
+
[COLOR.ND_GOLD]: '#ae9142',
|
|
67
|
+
[COLOR.ND_GOLD_LIGHT]: '#d39f10',
|
|
68
|
+
[COLOR.ND_GOLD_DARK]: '#8c7535',
|
|
52
69
|
[COLOR.ND_BLUE]: '#0c2340',
|
|
70
|
+
[COLOR.ND_BLUE_DARK]: '#081629',
|
|
53
71
|
[COLOR.ND_BLUE_LIGHT]: '#143865',
|
|
54
|
-
[COLOR.
|
|
72
|
+
[COLOR.ND_BLUE_BRIGHT]: '#1c4f8f',
|
|
55
73
|
[COLOR.ND_SKY_BLUE]: '#e1e8f2',
|
|
56
74
|
[COLOR.ND_SKY_BLUE_DARK]: '#c1cddd',
|
|
57
75
|
[COLOR.ND_METALLIC_GOLD]: '#ae9142',
|
package/dist/theme/index.d.ts
CHANGED
|
@@ -11,16 +11,25 @@ export declare const theme: {
|
|
|
11
11
|
background: string;
|
|
12
12
|
transparent: string;
|
|
13
13
|
primary: string;
|
|
14
|
+
textOnPrimary: string;
|
|
14
15
|
primaryHighlight: string;
|
|
15
16
|
secondary: string;
|
|
16
|
-
secondaryHighlight: string;
|
|
17
|
-
textOnPrimary: string;
|
|
18
17
|
textOnSecondary: string;
|
|
18
|
+
secondaryHighlight: string;
|
|
19
|
+
white: string;
|
|
20
|
+
black: string;
|
|
21
|
+
darkGray: string;
|
|
22
|
+
gray: string;
|
|
19
23
|
lightGray: string;
|
|
20
|
-
|
|
24
|
+
extraLightGray: string;
|
|
25
|
+
extraExtraLightGray: string;
|
|
21
26
|
ndBlue: string;
|
|
27
|
+
ndBlueDark: string;
|
|
22
28
|
ndBlueLight: string;
|
|
29
|
+
ndBlueBright: string;
|
|
23
30
|
ndGold: string;
|
|
31
|
+
ndGoldLight: string;
|
|
32
|
+
ndGoldDark: string;
|
|
24
33
|
ndSkyBlue: string;
|
|
25
34
|
ndSkyBlueDark: string;
|
|
26
35
|
ndMetallicGold: string;
|
|
@@ -87,23 +96,32 @@ export type StylesProp = ThemeUICSSObject & {
|
|
|
87
96
|
export type StyledElementProps<E extends Element, CustomProps = object, Children = React.ReactNode> = {
|
|
88
97
|
sx?: StylesProp;
|
|
89
98
|
children?: Children;
|
|
90
|
-
} & Omit<React.HTMLAttributes<E>, 'children'> & CustomProps;
|
|
99
|
+
} & Omit<React.HTMLAttributes<E>, 'children' | 'onChange'> & CustomProps;
|
|
91
100
|
export declare const useTheme: () => {
|
|
92
101
|
colors: {
|
|
93
102
|
text: string;
|
|
94
103
|
background: string;
|
|
95
104
|
transparent: string;
|
|
96
105
|
primary: string;
|
|
106
|
+
textOnPrimary: string;
|
|
97
107
|
primaryHighlight: string;
|
|
98
108
|
secondary: string;
|
|
99
|
-
secondaryHighlight: string;
|
|
100
|
-
textOnPrimary: string;
|
|
101
109
|
textOnSecondary: string;
|
|
110
|
+
secondaryHighlight: string;
|
|
111
|
+
white: string;
|
|
112
|
+
black: string;
|
|
113
|
+
darkGray: string;
|
|
114
|
+
gray: string;
|
|
102
115
|
lightGray: string;
|
|
103
|
-
|
|
116
|
+
extraLightGray: string;
|
|
117
|
+
extraExtraLightGray: string;
|
|
104
118
|
ndBlue: string;
|
|
119
|
+
ndBlueDark: string;
|
|
105
120
|
ndBlueLight: string;
|
|
121
|
+
ndBlueBright: string;
|
|
106
122
|
ndGold: string;
|
|
123
|
+
ndGoldLight: string;
|
|
124
|
+
ndGoldDark: string;
|
|
107
125
|
ndSkyBlue: string;
|
|
108
126
|
ndSkyBlueDark: string;
|
|
109
127
|
ndMetallicGold: string;
|