@ndlib/component-library 0.0.98 → 0.0.100
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 +1 -0
- package/dist/components/composites/Card/Card.stories.js +5 -1
- package/dist/components/composites/Card/index.d.ts +1 -0
- package/dist/components/composites/Card/index.js +3 -2
- package/dist/components/composites/NavMenu/index.js +3 -3
- package/dist/components/elements/Fields/Select/index.js +3 -3
- package/dist/components/elements/List/index.js +0 -1
- package/dist/components/elements/Markdown/Markdown.stories.d.ts +1 -0
- package/dist/components/elements/Markdown/Markdown.stories.js +15 -0
- package/dist/components/elements/Markdown/index.d.ts +2 -1
- package/dist/components/elements/Markdown/index.js +14 -14
- package/dist/components/providers/alerts.js +1 -1
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ type Story = StoryObj<typeof Card>;
|
|
|
6
6
|
export declare const Default: Story;
|
|
7
7
|
export declare const TruncateHeadline: Story;
|
|
8
8
|
export declare const Horizontal: Story;
|
|
9
|
+
export declare const CustomBackgroundColor: Story;
|
|
9
10
|
export declare const DateCards: Story;
|
|
10
11
|
export declare const Clickable: Story;
|
|
11
12
|
export declare const Raised: Story;
|
|
@@ -93,8 +93,12 @@ export const Horizontal = {
|
|
|
93
93
|
render: () => (_jsx(Column, { children: horizontalCards.map((props, i) => (_createElement(Card, Object.assign({}, props, { key: i, layout: CARD_LAYOUT.HORIZONTAL })))) })),
|
|
94
94
|
args: {},
|
|
95
95
|
};
|
|
96
|
+
export const CustomBackgroundColor = {
|
|
97
|
+
render: () => (_jsx(Column, { children: headlinedCards.map((props, i) => (_createElement(Card, Object.assign({}, props, { key: i, backgroundColor: COLOR.ND_SKY_BLUE })))) })),
|
|
98
|
+
args: {},
|
|
99
|
+
};
|
|
96
100
|
export const DateCards = {
|
|
97
|
-
render: () => (_jsx(Column, { children: dateCards.map((props, i) => (_createElement(Card, Object.assign({}, props, { key: i, layout: CARD_LAYOUT.HORIZONTAL, sx: { height: '120px' } })))) })),
|
|
101
|
+
render: () => (_jsx(Column, { children: dateCards.map((props, i) => (_createElement(Card, Object.assign({}, props, { key: i, layout: CARD_LAYOUT.HORIZONTAL, sx: { height: '120px' }, backgroundColor: COLOR.TRANSPARENT })))) })),
|
|
98
102
|
args: {},
|
|
99
103
|
};
|
|
100
104
|
export const Clickable = {
|
|
@@ -52,7 +52,7 @@ const DateDisplay = ({ date: dateString }) => {
|
|
|
52
52
|
mt: 1,
|
|
53
53
|
} }, { children: MONTH_LABELS[date.getMonth()] }))] })));
|
|
54
54
|
};
|
|
55
|
-
export const Card = ({ size, displayDate, headline, image, layout, onClick, raised, truncateHeadlineAfter, heading, headingStyles, headingIcon, headingAction, sx, imageHeight: imageHeightProp, imageWidth: imageWidthProp, children, }) => {
|
|
55
|
+
export const Card = ({ size, displayDate, headline, image, layout, onClick, raised, truncateHeadlineAfter, heading, headingStyles, headingIcon, headingAction, backgroundColor, sx, imageHeight: imageHeightProp, imageWidth: imageWidthProp, children, }) => {
|
|
56
56
|
const theme = useTheme();
|
|
57
57
|
const contentPaddingX = size === CARD_SIZE.SM ? 3 : 4;
|
|
58
58
|
const isVertical = !layout || layout === CARD_LAYOUT.VERTICAL;
|
|
@@ -71,7 +71,7 @@ export const Card = ({ size, displayDate, headline, image, layout, onClick, rais
|
|
|
71
71
|
if (onClick && e.key === KEY_CODES.ENTER) {
|
|
72
72
|
onClick();
|
|
73
73
|
}
|
|
74
|
-
}, 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
|
|
74
|
+
}, tabIndex: onClick ? 0 : undefined, sx: Object.assign({ boxShadow: raised || heading ? theme.boxShadow.NORMAL : undefined, width: !isVertical && '100%', backgroundColor: backgroundColor ? backgroundColor : COLOR.WHITE, 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
|
|
75
75
|
? {
|
|
76
76
|
transform: 'scale(1.01)',
|
|
77
77
|
borderColor: COLOR.ND_SKY_BLUE_DARK,
|
|
@@ -82,6 +82,7 @@ export const Card = ({ size, displayDate, headline, image, layout, onClick, rais
|
|
|
82
82
|
height: imageHeight,
|
|
83
83
|
} })), 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: {
|
|
84
84
|
color: COLOR.WHITE,
|
|
85
|
+
mt: 0,
|
|
85
86
|
whiteSpace: 'nowrap',
|
|
86
87
|
} }, { 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: { mt: 0 } }, { 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'
|
|
87
88
|
? children({ isHovered, activeBackground })
|
|
@@ -18,7 +18,7 @@ import { Row } from '../../elements/layout/Row';
|
|
|
18
18
|
import { Column } from '../../elements/layout/Column';
|
|
19
19
|
import { HEADING_SIZE, Heading } from '../../elements/text/Heading';
|
|
20
20
|
import { Link } from '../../elements/Link';
|
|
21
|
-
import { FONT_WEIGHT } from '../../../theme/typography';
|
|
21
|
+
import { FONT_SIZE, FONT_WEIGHT } from '../../../theme/typography';
|
|
22
22
|
import { COLOR } from '../../../theme/colors';
|
|
23
23
|
import { importedDefaultComponentShim } from '../../../utils/misc';
|
|
24
24
|
const ChevronRightIcon = importedDefaultComponentShim(_ChevronRightIcon);
|
|
@@ -44,12 +44,12 @@ export const NavMenu = (props) => {
|
|
|
44
44
|
const link = '//' + document.location.host + topLevelMenuId;
|
|
45
45
|
const category = topLevelMenuId.charAt(1).toUpperCase() + topLevelMenuId.slice(2);
|
|
46
46
|
return (_jsxs(Column, Object.assign({ sx: {
|
|
47
|
-
flexBasis: '
|
|
47
|
+
flexBasis: '300px',
|
|
48
48
|
py: 2,
|
|
49
49
|
px: 4,
|
|
50
50
|
flexShrink: 0,
|
|
51
51
|
flexGrow: 0,
|
|
52
|
-
} }, { children: [_jsx(Heading, Object.assign({ standalone: true, size: HEADING_SIZE.SM, underline: true }, getMenuItemProps(submenuPath), { children: submenuItem.label })), _jsx(List, Object.assign({}, getMenuProps(submenuPath), { icon: ChevronRightIcon }, { children: leafMenuItems.map((leafMenuItem, i) => {
|
|
52
|
+
} }, { children: [_jsx(Heading, Object.assign({ standalone: true, size: HEADING_SIZE.SM, underline: true }, getMenuItemProps(submenuPath), { children: submenuItem.label })), _jsx(List, Object.assign({}, getMenuProps(submenuPath), { icon: ChevronRightIcon, iconSize: FONT_SIZE.MS }, { children: leafMenuItems.map((leafMenuItem, i) => {
|
|
53
53
|
var _a;
|
|
54
54
|
const leafMenuPath = submenuPath.concat(leafMenuItem.id);
|
|
55
55
|
return (_jsx(ListItem, Object.assign({ index: i, sx: { mt: 2 } }, getMenuItemProps(leafMenuPath), { children: _jsx(Link, Object.assign({ to: (_a = leafMenuItem === null || leafMenuItem === void 0 ? void 0 : leafMenuItem.action) === null || _a === void 0 ? void 0 : _a.to, sx: {
|
|
@@ -131,7 +131,7 @@ export function Select({ size: sizeParam, placeholder, leftIcon, value, label, o
|
|
|
131
131
|
borderWidth: '1px',
|
|
132
132
|
overflow: 'hidden',
|
|
133
133
|
minWidth: '0%',
|
|
134
|
-
borderColor: inverted ? COLOR.
|
|
134
|
+
borderColor: inverted ? COLOR.WHITE : COLOR.LIGHT_GRAY,
|
|
135
135
|
zIndex: theme.zIndex.ELEVATED,
|
|
136
136
|
} }, { children: _jsx("legend", Object.assign({ style: {
|
|
137
137
|
width: 'auto',
|
|
@@ -155,7 +155,7 @@ export function Select({ size: sizeParam, placeholder, leftIcon, value, label, o
|
|
|
155
155
|
left: '0.5rem',
|
|
156
156
|
lineHeight: 1,
|
|
157
157
|
zIndex: theme.zIndex.ELEVATED,
|
|
158
|
-
color: inverted ? COLOR.
|
|
158
|
+
color: inverted ? COLOR.WHITE : COLOR.PRIMARY,
|
|
159
159
|
px: 1,
|
|
160
160
|
top: labelOffsetMap[size],
|
|
161
161
|
} }, { children: label })), _jsx(Button, Object.assign({ ref: refs.setReference, disableFocusStyles: true, role: "combobox", "aria-controls": listboxId, "aria-expanded": isOpen, "aria-autocomplete": "none", "aria-activedescendant": isOpen && stagedOptionValue
|
|
@@ -167,7 +167,7 @@ export function Select({ size: sizeParam, placeholder, leftIcon, value, label, o
|
|
|
167
167
|
else {
|
|
168
168
|
close();
|
|
169
169
|
}
|
|
170
|
-
}, color: inverted ? COLOR.
|
|
170
|
+
}, color: inverted ? COLOR.WHITE : COLOR.TEXT, sx: Object.assign({ height, width: '100%', border: 'solid 0px', flexDirection: 'row', alignItems: 'center', position: 'relative', zIndex: theme.zIndex.NORMAL, background: 'none' }, typographyStyles), leftIcon: leftIcon, rightIcon: ArrowDropDownIcon }, { children: currentOption ? renderOptionLabel(currentOption) : placeholder })), isOpen && (_jsx(ListBox, { id: listboxId, options: options, selected: value, focused: stagedOptionValue, selectOption: (option) => {
|
|
171
171
|
onSelectOption && onSelectOption(option.value);
|
|
172
172
|
close();
|
|
173
173
|
}, ref: refs.setFloating, renderOption: renderOption, sx: {
|
|
@@ -93,7 +93,6 @@ export const ListItem = (_a) => {
|
|
|
93
93
|
const typographyStyles = getTypographyStyles(sizeTypographyMap[size]);
|
|
94
94
|
const lineHeight = useLinesHeight({ typography, lines: 1 });
|
|
95
95
|
const tabIndex = tabIndexParam || (onClick ? 0 : undefined);
|
|
96
|
-
console.log('rendering tab index', tabIndex);
|
|
97
96
|
return (_jsxs("li", Object.assign({ sx: Object.assign(Object.assign({ depth, display: 'flex', mt: index === 0 && depth === 0 ? 0 : marginSizeMap[size], ml: 1 }, typographyStyles), sx), tabIndex: tabIndex }, rest, { children: [ordered ? (_jsxs(Label, Object.assign({ standalone: true, sx: { mr: 2 } }, { children: [index + 1, "."] }))) : (_jsx(Column, Object.assign({ sx: { height: lineHeight }, justify: "center" }, { children: _jsx(Icon, { icon: icon, color: iconColor, size: iconSize, onClick: onIconClick, "aria-label": iconLabel, sx: {
|
|
98
97
|
mr: 3,
|
|
99
98
|
alignItems: 'flex-start',
|
|
@@ -6,5 +6,6 @@ type Story = StoryObj<typeof Markdown>;
|
|
|
6
6
|
export declare const Default: Story;
|
|
7
7
|
export declare const WithHtml: Story;
|
|
8
8
|
export declare const CustomizeImages: Story;
|
|
9
|
+
export declare const CustomizeStyles: Story;
|
|
9
10
|
export declare const CustomHtmlSanitize: Story;
|
|
10
11
|
export declare const NoHtml: Story;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { DEFAULT_ALLOWED_ATTRIBUTES, DEFAULT_ALLOWED_TAGS, Markdown } from '.';
|
|
3
|
+
import { FONT_WEIGHT } from '../../../theme/typography';
|
|
4
|
+
import { COLOR } from '../../../theme/colors';
|
|
3
5
|
const meta = {
|
|
4
6
|
title: 'Elements/Markdown',
|
|
5
7
|
component: Markdown,
|
|
@@ -85,6 +87,19 @@ export const CustomizeImages = {
|
|
|
85
87
|
content: startingContent,
|
|
86
88
|
},
|
|
87
89
|
};
|
|
90
|
+
export const CustomizeStyles = {
|
|
91
|
+
render: (args) => (_jsx(Markdown, Object.assign({}, args, { customStyles: {
|
|
92
|
+
p: {
|
|
93
|
+
fontWeight: FONT_WEIGHT.BOLD,
|
|
94
|
+
},
|
|
95
|
+
h2: {
|
|
96
|
+
color: COLOR.SECONDARY,
|
|
97
|
+
},
|
|
98
|
+
} }))),
|
|
99
|
+
args: {
|
|
100
|
+
content: startingContent,
|
|
101
|
+
},
|
|
102
|
+
};
|
|
88
103
|
export const CustomHtmlSanitize = {
|
|
89
104
|
render: (args) => _jsx(Markdown, Object.assign({}, args)),
|
|
90
105
|
args: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { StyledElementProps } from '../../../theme';
|
|
2
|
+
import { StyledElementProps, StylesProp } from '../../../theme';
|
|
3
3
|
import sanitizeHtml from 'sanitize-html';
|
|
4
4
|
export declare const DEFAULT_ALLOWED_TAGS: string[];
|
|
5
5
|
export declare const DEFAULT_ALLOWED_ATTRIBUTES: {
|
|
@@ -17,6 +17,7 @@ type MarkdownProps = StyledElementProps<HTMLDivElement, {
|
|
|
17
17
|
allowedIframeDomains?: string[];
|
|
18
18
|
allowedAttributes?: sanitizeHtml.IOptions['allowedAttributes'];
|
|
19
19
|
};
|
|
20
|
+
customStyles?: Record<string, StylesProp>;
|
|
20
21
|
}>;
|
|
21
22
|
export declare const Markdown: React.FC<MarkdownProps>;
|
|
22
23
|
export {};
|
|
@@ -38,7 +38,7 @@ const dynamicTopMarginStyles = {
|
|
|
38
38
|
},
|
|
39
39
|
};
|
|
40
40
|
export const Markdown = (_a) => {
|
|
41
|
-
var { content, enableHtml, sanitizeHtmlOptions, imageStyles, headingLevelOffset = 1 } = _a, rest = __rest(_a, ["content", "enableHtml", "sanitizeHtmlOptions", "imageStyles", "headingLevelOffset"]);
|
|
41
|
+
var { content, enableHtml, sanitizeHtmlOptions, imageStyles, customStyles = {}, headingLevelOffset = 1 } = _a, rest = __rest(_a, ["content", "enableHtml", "sanitizeHtmlOptions", "imageStyles", "customStyles", "headingLevelOffset"]);
|
|
42
42
|
let sanitizedContent = content;
|
|
43
43
|
if (enableHtml) {
|
|
44
44
|
sanitizedContent = sanitizeHtml(content, {
|
|
@@ -49,22 +49,22 @@ export const Markdown = (_a) => {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
return (_jsx("div", Object.assign({}, rest, { children: _jsx(ReactMarkdown, Object.assign({ rehypePlugins: enableHtml ? [rehypeRaw] : [], components: {
|
|
52
|
-
h1: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.XL }, props, { level: props.level + headingLevelOffset, standalone: true, sx: dynamicTopMarginStyles }))),
|
|
53
|
-
h2: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.LG }, props, { level: props.level + headingLevelOffset, standalone: true, sx: dynamicTopMarginStyles }))),
|
|
54
|
-
h3: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD }, props, { level: props.level + headingLevelOffset, standalone: true, sx: dynamicTopMarginStyles }))),
|
|
55
|
-
h4: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.SM }, props, { level: props.level + headingLevelOffset, standalone: true, sx: dynamicTopMarginStyles }))),
|
|
56
|
-
h5: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.SM }, props, { standalone: true, level: props.level + headingLevelOffset, sx: dynamicTopMarginStyles }))),
|
|
57
|
-
h6: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.SM }, props, { standalone: true, level: props.level + headingLevelOffset, sx: dynamicTopMarginStyles }))),
|
|
58
|
-
ol: (props) => _jsx(List, Object.assign({}, props, { ordered: true, sx: { mt: 4 } })),
|
|
59
|
-
ul: (props) => _jsx(List, Object.assign({}, props, { sx: { mt: 4 } })),
|
|
52
|
+
h1: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.XL }, props, { level: props.level + headingLevelOffset, standalone: true, sx: Object.assign(Object.assign({}, dynamicTopMarginStyles), customStyles.h1) }))),
|
|
53
|
+
h2: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.LG }, props, { level: props.level + headingLevelOffset, standalone: true, sx: Object.assign(Object.assign({}, dynamicTopMarginStyles), customStyles.h2) }))),
|
|
54
|
+
h3: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD }, props, { level: props.level + headingLevelOffset, standalone: true, sx: Object.assign(Object.assign({}, dynamicTopMarginStyles), customStyles.h3) }))),
|
|
55
|
+
h4: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.SM }, props, { level: props.level + headingLevelOffset, standalone: true, sx: Object.assign(Object.assign({}, dynamicTopMarginStyles), customStyles.h4) }))),
|
|
56
|
+
h5: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.SM }, props, { standalone: true, level: props.level + headingLevelOffset, sx: Object.assign(Object.assign({}, dynamicTopMarginStyles), customStyles.h5) }))),
|
|
57
|
+
h6: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.SM }, props, { standalone: true, level: props.level + headingLevelOffset, sx: Object.assign(Object.assign({}, dynamicTopMarginStyles), customStyles.h6) }))),
|
|
58
|
+
ol: (props) => (_jsx(List, Object.assign({}, props, { ordered: true, sx: Object.assign({ mt: 4 }, customStyles.ol) }))),
|
|
59
|
+
ul: (props) => (_jsx(List, Object.assign({}, props, { sx: Object.assign({ mt: 4 }, customStyles.ul) }))),
|
|
60
60
|
li: (_a) => {
|
|
61
61
|
var { index, ordered } = _a, props = __rest(_a, ["index", "ordered"]);
|
|
62
|
-
return (_jsx(ListItem, Object.assign({ index: index }, props)));
|
|
62
|
+
return (_jsx(ListItem, Object.assign({ index: index }, props, { sx: customStyles.li })));
|
|
63
63
|
},
|
|
64
|
-
p: (props) => (_jsx(Paragraph, Object.assign({}, props, { sx: Object.assign(Object.assign({}, dynamicTopMarginStyles), { fontSize: 'inherit' }) }))),
|
|
65
|
-
strong: (props) => _jsx(Bold, Object.assign({}, props)),
|
|
66
|
-
em: (props) => _jsx(Italic, Object.assign({}, props)),
|
|
64
|
+
p: (props) => (_jsx(Paragraph, Object.assign({}, props, { sx: Object.assign(Object.assign(Object.assign({}, dynamicTopMarginStyles), { fontSize: 'inherit' }), customStyles.p) }))),
|
|
65
|
+
strong: (props) => _jsx(Bold, Object.assign({}, props, { sx: customStyles.strong })),
|
|
66
|
+
em: (props) => _jsx(Italic, Object.assign({}, props, { sx: customStyles.em })),
|
|
67
67
|
img: (props) => _jsx("img", Object.assign({}, props, { style: imageStyles })),
|
|
68
|
-
blockquote: (props) => (_jsx(BlockQuote, Object.assign({}, props, { sx: Object.assign(Object.assign({}, dynamicTopMarginStyles), { my: 5 }) }))),
|
|
68
|
+
blockquote: (props) => (_jsx(BlockQuote, Object.assign({}, props, { sx: Object.assign(Object.assign(Object.assign({}, dynamicTopMarginStyles), { my: 5 }), customStyles.blockquote) }))),
|
|
69
69
|
} }, { children: sanitizedContent })) })));
|
|
70
70
|
};
|