@dxc-technology/halstack-react 9.0.1 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HalstackContext.d.ts +4 -1
- package/HalstackContext.js +1 -1
- package/accordion/Accordion.stories.tsx +1 -1
- package/bleed/Bleed.stories.tsx +1 -0
- package/button/Button.js +0 -1
- package/button/Button.stories.tsx +1 -1
- package/flex/Flex.stories.tsx +19 -24
- package/grid/Grid.d.ts +7 -0
- package/grid/Grid.js +91 -0
- package/grid/Grid.stories.tsx +219 -0
- package/grid/types.d.ts +115 -0
- package/grid/types.js +5 -0
- package/inset/Inset.stories.tsx +1 -0
- package/layout/ApplicationLayout.d.ts +2 -2
- package/layout/types.d.ts +2 -3
- package/main.d.ts +2 -1
- package/main.js +8 -0
- package/package.json +1 -1
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +51 -0
- package/sidenav/Sidenav.d.ts +2 -2
- package/sidenav/Sidenav.js +49 -75
- package/sidenav/Sidenav.stories.tsx +60 -60
- package/sidenav/types.d.ts +21 -18
- package/tabs/Tab.js +1 -2
- package/tabs/Tabs.js +10 -14
- package/textarea/Textarea.js +0 -1
- package/textarea/Textarea.test.js +1 -3
- package/utils/FocusLock.js +1 -1
package/HalstackContext.d.ts
CHANGED
|
@@ -432,7 +432,10 @@ declare const HalstackContext: React.Context<DeepPartial<{
|
|
|
432
432
|
hamburguerIconColor: string;
|
|
433
433
|
hamburguerHoverColor: string;
|
|
434
434
|
logo: string;
|
|
435
|
-
logoResponsive: string;
|
|
435
|
+
logoResponsive: string; /**
|
|
436
|
+
* This type is used to allow partial themes and labels objects to be passed to the HalstackProvider.
|
|
437
|
+
* This is an extension of the already extisting Partial type, which only allows one level of partiality.
|
|
438
|
+
*/
|
|
436
439
|
logoHeight: string;
|
|
437
440
|
logoWidth: string;
|
|
438
441
|
menuBackgroundColor: string;
|
package/HalstackContext.js
CHANGED
|
@@ -291,7 +291,7 @@ var parseTheme = function parseTheme(theme) {
|
|
|
291
291
|
};
|
|
292
292
|
|
|
293
293
|
var parseLabels = function parseLabels(labels) {
|
|
294
|
-
var parsedLabels =
|
|
294
|
+
var parsedLabels = _variables.defaultTranslatedComponentLabels;
|
|
295
295
|
Object.keys(labels).map(function (component) {
|
|
296
296
|
if (parsedLabels[component]) {
|
|
297
297
|
Object.keys(parsedLabels[component]).map(function (label) {
|
|
@@ -131,7 +131,7 @@ export const Chromatic = () => (
|
|
|
131
131
|
<DxcAccordion
|
|
132
132
|
label="Accordion"
|
|
133
133
|
assistiveText="Assistive text"
|
|
134
|
-
icon="https://
|
|
134
|
+
icon="https://www.freepnglogos.com/uploads/facebook-logo-design-1.png"
|
|
135
135
|
>
|
|
136
136
|
<div>
|
|
137
137
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo
|
package/bleed/Bleed.stories.tsx
CHANGED
package/button/Button.js
CHANGED
|
@@ -75,7 +75,6 @@ var DxcButton = function DxcButton(_ref) {
|
|
|
75
75
|
type: type,
|
|
76
76
|
mode: mode !== "primary" && mode !== "secondary" && mode !== "text" ? "primary" : mode,
|
|
77
77
|
disabled: disabled,
|
|
78
|
-
"aria-disabled": disabled,
|
|
79
78
|
tabIndex: disabled ? -1 : tabIndex,
|
|
80
79
|
backgroundType: backgroundType,
|
|
81
80
|
size: size,
|
|
@@ -98,7 +98,7 @@ export const Chromatic = () => (
|
|
|
98
98
|
</ExampleContainer>
|
|
99
99
|
<ExampleContainer>
|
|
100
100
|
<Title title="Big icon (image)" theme="light" level={4} />
|
|
101
|
-
<DxcButton icon="https://
|
|
101
|
+
<DxcButton icon="https://www.freepnglogos.com/uploads/facebook-logo-design-1.png" />
|
|
102
102
|
</ExampleContainer>
|
|
103
103
|
<ExampleContainer>
|
|
104
104
|
<Title title="Small icon" theme="light" level={4} />
|
package/flex/Flex.stories.tsx
CHANGED
|
@@ -14,19 +14,19 @@ export const Chromatic = () => (
|
|
|
14
14
|
<Container>
|
|
15
15
|
<DxcFlex>
|
|
16
16
|
<Placeholder />
|
|
17
|
-
<Placeholder
|
|
17
|
+
<Placeholder minWidth="50px" />
|
|
18
18
|
<Placeholder />
|
|
19
|
-
<Placeholder
|
|
20
|
-
<Placeholder
|
|
19
|
+
<Placeholder minWidth="50px" />
|
|
20
|
+
<Placeholder minWidth="50px" />
|
|
21
21
|
</DxcFlex>
|
|
22
22
|
</Container>
|
|
23
23
|
<Title title="Direction column, wrap, justify content end, align items center and gap" level={4} />
|
|
24
24
|
<Container>
|
|
25
25
|
<DxcFlex direction="column" wrap="wrap" justifyContent="end" alignItems="center" gap="20px">
|
|
26
26
|
<Placeholder />
|
|
27
|
-
<Placeholder
|
|
27
|
+
<Placeholder minWidth="100px" />
|
|
28
28
|
<Placeholder />
|
|
29
|
-
<Placeholder
|
|
29
|
+
<Placeholder minWidth="100px" />
|
|
30
30
|
<Placeholder />
|
|
31
31
|
</DxcFlex>
|
|
32
32
|
</Container>
|
|
@@ -37,13 +37,13 @@ export const Chromatic = () => (
|
|
|
37
37
|
<Placeholder />
|
|
38
38
|
<Placeholder />
|
|
39
39
|
<Placeholder />
|
|
40
|
-
<Placeholder
|
|
40
|
+
<Placeholder minWidth="100px" />
|
|
41
41
|
<Placeholder />
|
|
42
42
|
<Placeholder />
|
|
43
|
-
<Placeholder
|
|
43
|
+
<Placeholder minWidth="100px" />
|
|
44
44
|
<Placeholder />
|
|
45
45
|
<Placeholder />
|
|
46
|
-
<Placeholder
|
|
46
|
+
<Placeholder minWidth="100px" />
|
|
47
47
|
<Placeholder />
|
|
48
48
|
</DxcFlex>
|
|
49
49
|
</Container>
|
|
@@ -51,16 +51,16 @@ export const Chromatic = () => (
|
|
|
51
51
|
<Container height="75px">
|
|
52
52
|
<DxcFlex basis="100%">
|
|
53
53
|
<DxcFlex order={3} grow={1} alignSelf="flex-end">
|
|
54
|
-
<
|
|
54
|
+
<Placeholder width="100%" minWidth="0">order 3, grow 1, align self end</Placeholder>
|
|
55
55
|
</DxcFlex>
|
|
56
56
|
<DxcFlex order={-1} grow={4}>
|
|
57
|
-
<
|
|
57
|
+
<Placeholder width="100%" minWidth="0">order -1, grow 4</Placeholder>
|
|
58
58
|
</DxcFlex>
|
|
59
59
|
<DxcFlex order={5} grow={1}>
|
|
60
|
-
<
|
|
60
|
+
<Placeholder width="100%" minWidth="0">order 5, grow 1</Placeholder>
|
|
61
61
|
</DxcFlex>
|
|
62
62
|
<DxcFlex order={2} grow={2}>
|
|
63
|
-
<
|
|
63
|
+
<Placeholder width="100%" minWidth="0">order 2. grow 2</Placeholder>
|
|
64
64
|
</DxcFlex>
|
|
65
65
|
</DxcFlex>
|
|
66
66
|
</Container>
|
|
@@ -68,13 +68,13 @@ export const Chromatic = () => (
|
|
|
68
68
|
<Container>
|
|
69
69
|
<DxcFlex basis="600px">
|
|
70
70
|
<DxcFlex shrink={4} basis="400px">
|
|
71
|
-
<
|
|
71
|
+
<Placeholder width="100%" minWidth="0">shrink 4</Placeholder>
|
|
72
72
|
</DxcFlex>
|
|
73
73
|
<DxcFlex shrink={2} basis="400px">
|
|
74
|
-
<
|
|
74
|
+
<Placeholder width="100%" minWidth="0">shrink 2</Placeholder>
|
|
75
75
|
</DxcFlex>
|
|
76
76
|
<DxcFlex shrink={1} basis="400px">
|
|
77
|
-
<
|
|
77
|
+
<Placeholder width="100%" minWidth="0">shrink 1</Placeholder>
|
|
78
78
|
</DxcFlex>
|
|
79
79
|
</DxcFlex>
|
|
80
80
|
</Container>
|
|
@@ -88,16 +88,11 @@ const Container = styled.div<{ height?: string }>`
|
|
|
88
88
|
${({ height }) => (height ? `height: ${height}` : "max-height: 150px")};
|
|
89
89
|
`;
|
|
90
90
|
|
|
91
|
-
const Placeholder = styled.div<{ width?: string }>`
|
|
91
|
+
const Placeholder = styled.div<{ minWidth?: string, width?: string }>`
|
|
92
92
|
height: 40px;
|
|
93
|
-
min-width: ${({
|
|
94
|
-
|
|
95
|
-
background-color: #e5d5f6;
|
|
96
|
-
`;
|
|
97
|
-
|
|
98
|
-
const PlaceholderGrowAndShrink = styled.div`
|
|
99
|
-
height: 40px;
|
|
100
|
-
width: 100%;
|
|
93
|
+
min-width: ${({ minWidth }) => minWidth ?? "200px"};
|
|
94
|
+
width: ${({ width }) => width};
|
|
101
95
|
border: 1px solid #a46ede;
|
|
96
|
+
border-radius: 0.5rem;
|
|
102
97
|
background-color: #e5d5f6;
|
|
103
98
|
`;
|
package/grid/Grid.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import GridPropsType, { GridItemProps } from "./types";
|
|
3
|
+
declare const DxcGrid: {
|
|
4
|
+
(props: GridPropsType): JSX.Element;
|
|
5
|
+
GridItem: import("styled-components").StyledComponent<"div", any, GridItemProps, never>;
|
|
6
|
+
};
|
|
7
|
+
export default DxcGrid;
|
package/grid/Grid.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
|
+
|
|
16
|
+
var _templateObject, _templateObject2;
|
|
17
|
+
|
|
18
|
+
var DxcGrid = function DxcGrid(props) {
|
|
19
|
+
return /*#__PURE__*/_react["default"].createElement(Grid, props);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
var Grid = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: grid;\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n \n ", "\n ", "\n ", "\n ", "\n"])), function (_ref) {
|
|
23
|
+
var templateColumns = _ref.templateColumns;
|
|
24
|
+
return templateColumns && "grid-template-columns: ".concat(templateColumns.join(" "), ";");
|
|
25
|
+
}, function (_ref2) {
|
|
26
|
+
var templateRows = _ref2.templateRows;
|
|
27
|
+
return templateRows && "grid-template-rows: ".concat(templateRows.join(" "), ";");
|
|
28
|
+
}, function (_ref3) {
|
|
29
|
+
var templateAreas = _ref3.templateAreas;
|
|
30
|
+
return templateAreas && "grid-template-areas: ".concat(templateAreas.map(function (row) {
|
|
31
|
+
return "\"".concat(row, "\"");
|
|
32
|
+
}).join(" "), ";");
|
|
33
|
+
}, function (_ref4) {
|
|
34
|
+
var autoColumns = _ref4.autoColumns;
|
|
35
|
+
return autoColumns && "grid-auto-columns: ".concat(autoColumns, ";");
|
|
36
|
+
}, function (_ref5) {
|
|
37
|
+
var autoRows = _ref5.autoRows;
|
|
38
|
+
return autoRows && "grid-auto-rows: ".concat(autoRows, ";");
|
|
39
|
+
}, function (_ref6) {
|
|
40
|
+
var autoFlow = _ref6.autoFlow;
|
|
41
|
+
return autoFlow && "grid-auto-flow: ".concat(autoFlow, ";");
|
|
42
|
+
}, function (_ref7) {
|
|
43
|
+
var _gap$rowGap, _gap$columnGap;
|
|
44
|
+
|
|
45
|
+
var gap = _ref7.gap;
|
|
46
|
+
return gap != null && (typeof gap === "string" ? "gap: ".concat(gap, ";") : "row-gap: ".concat((_gap$rowGap = gap.rowGap) !== null && _gap$rowGap !== void 0 ? _gap$rowGap : "", "; column-gap: ").concat((_gap$columnGap = gap.columnGap) !== null && _gap$columnGap !== void 0 ? _gap$columnGap : "", ";"));
|
|
47
|
+
}, function (_ref8) {
|
|
48
|
+
var _placeItems$alignItem, _placeItems$justifyIt;
|
|
49
|
+
|
|
50
|
+
var placeItems = _ref8.placeItems;
|
|
51
|
+
return placeItems && (typeof placeItems === "string" ? "place-items: ".concat(placeItems) : "align-items: ".concat((_placeItems$alignItem = placeItems.alignItems) !== null && _placeItems$alignItem !== void 0 ? _placeItems$alignItem : "", "; justify-items: ").concat((_placeItems$justifyIt = placeItems.justifyItems) !== null && _placeItems$justifyIt !== void 0 ? _placeItems$justifyIt : "", ";"));
|
|
52
|
+
}, function (_ref9) {
|
|
53
|
+
var _placeContent$alignCo, _placeContent$justify;
|
|
54
|
+
|
|
55
|
+
var placeContent = _ref9.placeContent;
|
|
56
|
+
return placeContent && (typeof placeContent === "string" ? "place-content: ".concat(placeContent) : "align-content: ".concat((_placeContent$alignCo = placeContent.alignContent) !== null && _placeContent$alignCo !== void 0 ? _placeContent$alignCo : "", "; justify-content: ").concat((_placeContent$justify = placeContent.justifyContent) !== null && _placeContent$justify !== void 0 ? _placeContent$justify : "", ";"));
|
|
57
|
+
}, function (_ref10) {
|
|
58
|
+
var areaName = _ref10.areaName;
|
|
59
|
+
return areaName && "grid-area: ".concat(areaName, ";");
|
|
60
|
+
}, function (_ref11) {
|
|
61
|
+
var column = _ref11.column;
|
|
62
|
+
return column && "grid-column: ".concat(typeof column === "string" || typeof column === "number" ? column : "".concat(column.start, " / ").concat(column.end, ";"), ";");
|
|
63
|
+
}, function (_ref12) {
|
|
64
|
+
var row = _ref12.row;
|
|
65
|
+
return row && "grid-row: ".concat(typeof row === "string" || typeof row === "number" ? row : "".concat(row.start, " / ").concat(row.end, ";"), ";");
|
|
66
|
+
}, function (_ref13) {
|
|
67
|
+
var _placeSelf$alignSelf, _placeSelf$justifySel;
|
|
68
|
+
|
|
69
|
+
var placeSelf = _ref13.placeSelf;
|
|
70
|
+
return placeSelf && (typeof placeSelf === "string" ? "place-self: ".concat(placeSelf) : "align-self: ".concat((_placeSelf$alignSelf = placeSelf.alignSelf) !== null && _placeSelf$alignSelf !== void 0 ? _placeSelf$alignSelf : "", "; justify-self: ").concat((_placeSelf$justifySel = placeSelf.justifySelf) !== null && _placeSelf$justifySel !== void 0 ? _placeSelf$justifySel : "", ";"));
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
var GridItem = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n ", "\n ", "\n ", "\n ", "\n"])), function (_ref14) {
|
|
74
|
+
var areaName = _ref14.areaName;
|
|
75
|
+
return areaName && "grid-area: ".concat(areaName, ";");
|
|
76
|
+
}, function (_ref15) {
|
|
77
|
+
var column = _ref15.column;
|
|
78
|
+
return column && "grid-column: ".concat(typeof column === "string" || typeof column === "number" ? column : "".concat(column.start, " / ").concat(column.end, ";"), ";");
|
|
79
|
+
}, function (_ref16) {
|
|
80
|
+
var row = _ref16.row;
|
|
81
|
+
return row && "grid-row: ".concat(typeof row === "string" || typeof row === "number" ? row : "".concat(row.start, " / ").concat(row.end, ";"), ";");
|
|
82
|
+
}, function (_ref17) {
|
|
83
|
+
var _placeSelf$alignSelf2, _placeSelf$justifySel2;
|
|
84
|
+
|
|
85
|
+
var placeSelf = _ref17.placeSelf;
|
|
86
|
+
return placeSelf && (typeof placeSelf === "string" ? "place-self: ".concat(placeSelf) : "align-self: ".concat((_placeSelf$alignSelf2 = placeSelf.alignSelf) !== null && _placeSelf$alignSelf2 !== void 0 ? _placeSelf$alignSelf2 : "", "; justify-self: ").concat((_placeSelf$justifySel2 = placeSelf.justifySelf) !== null && _placeSelf$justifySel2 !== void 0 ? _placeSelf$justifySel2 : "", ";"));
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
DxcGrid.GridItem = GridItem;
|
|
90
|
+
var _default = DxcGrid;
|
|
91
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Title from "../../.storybook/components/Title";
|
|
3
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
4
|
+
import styled from "styled-components";
|
|
5
|
+
import DxcGrid from "./Grid";
|
|
6
|
+
import DxcInset from "../inset/Inset";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: "Grid",
|
|
10
|
+
component: DxcGrid,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const Chromatic = () => (
|
|
14
|
+
<>
|
|
15
|
+
<Title title="Default" level={4} />
|
|
16
|
+
<ExampleContainer>
|
|
17
|
+
<DxcGrid>
|
|
18
|
+
<ColoredContainer />
|
|
19
|
+
<ColoredContainer />
|
|
20
|
+
<ColoredContainer />
|
|
21
|
+
</DxcGrid>
|
|
22
|
+
</ExampleContainer>
|
|
23
|
+
<Title title="Place items" level={4} />
|
|
24
|
+
<ExampleContainer>
|
|
25
|
+
<DxcGrid templateRows={["200px"]} placeItems="center">
|
|
26
|
+
<ColoredContainer height="50px" width="50px" />
|
|
27
|
+
</DxcGrid>
|
|
28
|
+
<DxcGrid placeItems={{ justifyItems: "end" }}>
|
|
29
|
+
<ColoredContainer />
|
|
30
|
+
<ColoredContainer />
|
|
31
|
+
<ColoredContainer />
|
|
32
|
+
</DxcGrid>
|
|
33
|
+
<DxcGrid templateRows={["repeat(3, 100px)"]} placeItems={{ alignItems: "end", justifyItems: "center" }}>
|
|
34
|
+
<ColoredContainer height="50px" width="50px" />
|
|
35
|
+
<ColoredContainer height="50px" width="50px" />
|
|
36
|
+
<ColoredContainer height="50px" width="50px" />
|
|
37
|
+
</DxcGrid>
|
|
38
|
+
</ExampleContainer>
|
|
39
|
+
<Title title="Place content" level={4} />
|
|
40
|
+
<Container height="200px">
|
|
41
|
+
<DxcGrid placeContent="center">
|
|
42
|
+
<ColoredContainer height="50px" width="50px" />
|
|
43
|
+
<ColoredContainer height="50px" width="50px" />
|
|
44
|
+
</DxcGrid>
|
|
45
|
+
</Container>
|
|
46
|
+
<Container height="200px">
|
|
47
|
+
<DxcGrid placeContent={{ alignContent: "center" }}>
|
|
48
|
+
<ColoredContainer height="50px" width="50px" />
|
|
49
|
+
</DxcGrid>
|
|
50
|
+
</Container>
|
|
51
|
+
<Container height="200px">
|
|
52
|
+
<DxcGrid placeContent={{ alignContent: "center", justifyContent: "end" }}>
|
|
53
|
+
<ColoredContainer height="50px" width="50px" />
|
|
54
|
+
</DxcGrid>
|
|
55
|
+
</Container>
|
|
56
|
+
<Title title="Place self" level={4} />
|
|
57
|
+
<ExampleContainer>
|
|
58
|
+
<DxcGrid templateRows={["repeat(3, 100px)"]}>
|
|
59
|
+
<DxcGrid.GridItem placeSelf="center">
|
|
60
|
+
<ColoredContainer height="50px" width="50px" />
|
|
61
|
+
</DxcGrid.GridItem>
|
|
62
|
+
<DxcGrid.GridItem placeSelf={{ alignSelf: "end" }}>
|
|
63
|
+
<ColoredContainer height="40px" width="40px" />
|
|
64
|
+
<ColoredContainer height="30px" width="30px" />
|
|
65
|
+
</DxcGrid.GridItem>
|
|
66
|
+
<DxcGrid.GridItem placeSelf={{ alignSelf: "center", justifySelf: "end" }}>
|
|
67
|
+
<ColoredContainer height="50px" width="50px" />
|
|
68
|
+
</DxcGrid.GridItem>
|
|
69
|
+
</DxcGrid>
|
|
70
|
+
</ExampleContainer>
|
|
71
|
+
<Title title="Halstack layout using template areas" level={4} />
|
|
72
|
+
<ExampleContainer>
|
|
73
|
+
<DxcGrid
|
|
74
|
+
templateColumns={["repeat(4, 1fr)"]}
|
|
75
|
+
templateRows={["40px", "200px", "60px"]}
|
|
76
|
+
templateAreas={["header header header header", "sidenav main main main", "sidenav footer footer footer"]}
|
|
77
|
+
gap={{ rowGap: "0.5rem", columnGap: "1rem" }}
|
|
78
|
+
>
|
|
79
|
+
<DxcGrid.GridItem areaName="header" as="header">
|
|
80
|
+
<ColoredContainer height="100%" />
|
|
81
|
+
</DxcGrid.GridItem>
|
|
82
|
+
<DxcGrid.GridItem areaName="main" as="main">
|
|
83
|
+
<ColoredContainer height="100%" />
|
|
84
|
+
</DxcGrid.GridItem>
|
|
85
|
+
<DxcGrid.GridItem areaName="sidenav" as="nav">
|
|
86
|
+
<ColoredContainer height="100%" />
|
|
87
|
+
</DxcGrid.GridItem>
|
|
88
|
+
<DxcGrid.GridItem areaName="footer" as="footer">
|
|
89
|
+
<ColoredContainer height="100%" />
|
|
90
|
+
</DxcGrid.GridItem>
|
|
91
|
+
</DxcGrid>
|
|
92
|
+
</ExampleContainer>
|
|
93
|
+
<Title title="Template rows and columns with flexible sizes" level={4} />
|
|
94
|
+
<ExampleContainer>
|
|
95
|
+
<DxcGrid templateColumns={["1fr", "1fr", "1fr"]} templateRows={["1fr", "3fr", "1fr"]} gap="0.5rem">
|
|
96
|
+
<DxcGrid.GridItem column={{ start: 1, end: -1 }}>
|
|
97
|
+
<ColoredContainer color="yellow" height="100%">
|
|
98
|
+
Header
|
|
99
|
+
</ColoredContainer>
|
|
100
|
+
</DxcGrid.GridItem>
|
|
101
|
+
<DxcGrid.GridItem column={1}>
|
|
102
|
+
<ColoredContainer color="lightcyan" height="100%">
|
|
103
|
+
Sidenav
|
|
104
|
+
</ColoredContainer>
|
|
105
|
+
</DxcGrid.GridItem>
|
|
106
|
+
<DxcGrid
|
|
107
|
+
column={{ start: 2, end: -1 }}
|
|
108
|
+
templateRows={["repeat(4, 1fr)"]}
|
|
109
|
+
templateColumns={["repeat(2, 1fr)"]}
|
|
110
|
+
gap="1rem"
|
|
111
|
+
>
|
|
112
|
+
<ColoredContainer />
|
|
113
|
+
<ColoredContainer />
|
|
114
|
+
<ColoredContainer />
|
|
115
|
+
<ColoredContainer />
|
|
116
|
+
<ColoredContainer />
|
|
117
|
+
<ColoredContainer />
|
|
118
|
+
<ColoredContainer />
|
|
119
|
+
<ColoredContainer />
|
|
120
|
+
</DxcGrid>
|
|
121
|
+
<DxcGrid.GridItem column={{ start: 1, end: -1 }}>
|
|
122
|
+
<ColoredContainer color="black" height="100%">
|
|
123
|
+
Footer
|
|
124
|
+
</ColoredContainer>
|
|
125
|
+
</DxcGrid.GridItem>
|
|
126
|
+
</DxcGrid>
|
|
127
|
+
</ExampleContainer>
|
|
128
|
+
<Title title="Overlapping" level={4} />
|
|
129
|
+
<DxcInset bottom="2rem">
|
|
130
|
+
<ExampleContainer>
|
|
131
|
+
<DxcGrid templateRows={["50px", "50px"]}>
|
|
132
|
+
<ColoredContainer color="yellow" height="100px">
|
|
133
|
+
1
|
|
134
|
+
</ColoredContainer>
|
|
135
|
+
<ColoredContainer color="transparent" height="100px">
|
|
136
|
+
2
|
|
137
|
+
</ColoredContainer>
|
|
138
|
+
</DxcGrid>
|
|
139
|
+
</ExampleContainer>
|
|
140
|
+
</DxcInset>
|
|
141
|
+
<Title title="Implicit rows and columns" level={4} />
|
|
142
|
+
<ExampleContainer>
|
|
143
|
+
<DxcGrid templateColumns={["50px"]} templateRows={["50px", "50px"]} autoRows="50px" autoColumns="50px">
|
|
144
|
+
<DxcGrid.GridItem>
|
|
145
|
+
<ColoredContainer height="50px">1</ColoredContainer>
|
|
146
|
+
</DxcGrid.GridItem>
|
|
147
|
+
<DxcGrid.GridItem row={2}>
|
|
148
|
+
<ColoredContainer height="50px">3</ColoredContainer>
|
|
149
|
+
</DxcGrid.GridItem>
|
|
150
|
+
<DxcGrid.GridItem row={6} column={1}>
|
|
151
|
+
<ColoredContainer height="50px">5</ColoredContainer>
|
|
152
|
+
</DxcGrid.GridItem>
|
|
153
|
+
<DxcGrid.GridItem row={3}>
|
|
154
|
+
<ColoredContainer height="50px">4</ColoredContainer>
|
|
155
|
+
</DxcGrid.GridItem>
|
|
156
|
+
<DxcGrid.GridItem row={{ start: 1, end: 2 }} column={{ start: 5, end: "span 2" }}>
|
|
157
|
+
<ColoredContainer height="50px">2</ColoredContainer>
|
|
158
|
+
</DxcGrid.GridItem>
|
|
159
|
+
</DxcGrid>
|
|
160
|
+
</ExampleContainer>
|
|
161
|
+
<Title title="Autoflow 'row' (default)" level={4} />
|
|
162
|
+
<ExampleContainer>
|
|
163
|
+
<DxcGrid templateColumns={["repeat(5, 1fr)"]} templateRows={["1fr", "1fr"]} autoFlow="row" autoColumns="1fr">
|
|
164
|
+
<DxcGrid.GridItem row={{ start: 1, end: "span 2" }} column={1}>
|
|
165
|
+
<ColoredContainer height="100%">1</ColoredContainer>
|
|
166
|
+
</DxcGrid.GridItem>
|
|
167
|
+
<ColoredContainer color="lightyellow">2</ColoredContainer>
|
|
168
|
+
<ColoredContainer color="lightcyan">3</ColoredContainer>
|
|
169
|
+
<ColoredContainer color="lightgreen">4</ColoredContainer>
|
|
170
|
+
<DxcGrid.GridItem row={{ start: 1, end: -1 }} column={-2}>
|
|
171
|
+
<ColoredContainer color="lightpink" height="100%">
|
|
172
|
+
5
|
|
173
|
+
</ColoredContainer>
|
|
174
|
+
</DxcGrid.GridItem>
|
|
175
|
+
</DxcGrid>
|
|
176
|
+
</ExampleContainer>
|
|
177
|
+
<Title title="Autoflow 'column'" level={4} />
|
|
178
|
+
<ExampleContainer>
|
|
179
|
+
<DxcGrid templateColumns={["repeat(5, 1fr)"]} templateRows={["1fr", "1fr"]} autoFlow="column" autoColumns="1fr">
|
|
180
|
+
<DxcGrid.GridItem row={{ start: 1, end: -1 }} column={1}>
|
|
181
|
+
<ColoredContainer height="100%">1</ColoredContainer>
|
|
182
|
+
</DxcGrid.GridItem>
|
|
183
|
+
<ColoredContainer color="lightyellow">2</ColoredContainer>
|
|
184
|
+
<ColoredContainer color="lightcyan">3</ColoredContainer>
|
|
185
|
+
<ColoredContainer color="lightgreen">4</ColoredContainer>
|
|
186
|
+
<DxcGrid.GridItem row={{ start: 1, end: -1 }} column={-2}>
|
|
187
|
+
<ColoredContainer color="lightpink" height="100%">
|
|
188
|
+
5
|
|
189
|
+
</ColoredContainer>
|
|
190
|
+
</DxcGrid.GridItem>
|
|
191
|
+
</DxcGrid>
|
|
192
|
+
</ExampleContainer>
|
|
193
|
+
</>
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
const Container = styled.div<{ height?: string }>`
|
|
197
|
+
display: grid;
|
|
198
|
+
overflow: auto;
|
|
199
|
+
margin: 2.5rem;
|
|
200
|
+
${({ height }) => height && `height: ${height}`};
|
|
201
|
+
`;
|
|
202
|
+
|
|
203
|
+
const ColoredContainer = styled.div<{ color?: string; width?: string; height?: string }>`
|
|
204
|
+
box-sizing: border-box;
|
|
205
|
+
display: flex;
|
|
206
|
+
justify-content: center;
|
|
207
|
+
align-items: center;
|
|
208
|
+
background-color: ${({ color }) => color ?? "#e5d5f6"};
|
|
209
|
+
padding: 1rem;
|
|
210
|
+
border: 1px solid #a46ede;
|
|
211
|
+
border-radius: 0.5rem;
|
|
212
|
+
font-family: Open Sans, sans-serif;
|
|
213
|
+
font-size: 1.5rem;
|
|
214
|
+
font-weight: bold;
|
|
215
|
+
color: #a46ede;
|
|
216
|
+
|
|
217
|
+
${({ width }) => width && `width: ${width}`};
|
|
218
|
+
${({ height }) => height && `height: ${height}`};
|
|
219
|
+
`;
|
package/grid/types.d.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare type Spaces = "0rem" | "0.125rem" | "0.25rem" | "0.5rem" | "1rem" | "1.5rem" | "2rem" | "3rem" | "4rem" | "5rem";
|
|
3
|
+
declare type Gap = {
|
|
4
|
+
rowGap: Spaces;
|
|
5
|
+
columnGap?: Spaces;
|
|
6
|
+
} | {
|
|
7
|
+
rowGap?: Spaces;
|
|
8
|
+
columnGap: Spaces;
|
|
9
|
+
} | Spaces;
|
|
10
|
+
declare type GridCell = {
|
|
11
|
+
start: number | string;
|
|
12
|
+
end: number | string;
|
|
13
|
+
};
|
|
14
|
+
declare type PlaceSelfValues = "auto" | "start" | "end" | "center" | "stretch" | "baseline";
|
|
15
|
+
declare type PlaceContentValues = "normal" | "start" | "end" | "center" | "stretch" | "space-between" | "space-around" | "space-evenly" | "baseline";
|
|
16
|
+
declare type PlaceItemsValues = "normal" | "start" | "end" | "center" | "stretch" | "baseline";
|
|
17
|
+
declare type PlaceObject<Type, Suffix extends string> = {
|
|
18
|
+
[Property in keyof Type as `${string & Property}${Capitalize<string & Suffix>}`]: Type[Property];
|
|
19
|
+
};
|
|
20
|
+
declare type PlaceGeneric<PlaceValues, Element extends string> = PlaceObject<{
|
|
21
|
+
justify?: PlaceValues;
|
|
22
|
+
align: PlaceValues;
|
|
23
|
+
}, Element> | PlaceObject<{
|
|
24
|
+
justify: PlaceValues;
|
|
25
|
+
align?: PlaceValues;
|
|
26
|
+
}, Element> | PlaceValues;
|
|
27
|
+
export declare type GridItemProps = {
|
|
28
|
+
/**
|
|
29
|
+
* Sets the name of an item so that it can be referenced by a template created with the grid-template-areas property.
|
|
30
|
+
*/
|
|
31
|
+
areaName?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Sets the grid-column CSS property.
|
|
34
|
+
*
|
|
35
|
+
* See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column
|
|
36
|
+
*/
|
|
37
|
+
column?: number | string | GridCell;
|
|
38
|
+
/**
|
|
39
|
+
* Sets the grid-row CSS property.
|
|
40
|
+
*
|
|
41
|
+
* See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row
|
|
42
|
+
*/
|
|
43
|
+
row?: number | string | GridCell;
|
|
44
|
+
/**
|
|
45
|
+
* Sets the place-self CSS property.
|
|
46
|
+
*
|
|
47
|
+
* See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/place-self
|
|
48
|
+
*/
|
|
49
|
+
placeSelf?: PlaceGeneric<PlaceSelfValues, "self">;
|
|
50
|
+
/**
|
|
51
|
+
* Sets a custom HTML tag.
|
|
52
|
+
*/
|
|
53
|
+
as?: keyof HTMLElementTagNameMap;
|
|
54
|
+
/**
|
|
55
|
+
* Custom content inside the grid container.
|
|
56
|
+
*/
|
|
57
|
+
children: React.ReactNode;
|
|
58
|
+
};
|
|
59
|
+
declare type Props = GridItemProps & {
|
|
60
|
+
/**
|
|
61
|
+
* Sets the grid-auto-columns CSS property.
|
|
62
|
+
*
|
|
63
|
+
* See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns
|
|
64
|
+
*/
|
|
65
|
+
autoColumns?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Sets the grid-auto-flow CSS property.
|
|
68
|
+
*
|
|
69
|
+
* See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow
|
|
70
|
+
*/
|
|
71
|
+
autoFlow?: "row" | "column" | "row dense" | "column dense";
|
|
72
|
+
/**
|
|
73
|
+
* Sets the grid-auto-rows CSS property.
|
|
74
|
+
*
|
|
75
|
+
* See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows
|
|
76
|
+
*/
|
|
77
|
+
autoRows?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Sets the gap CSS property.
|
|
80
|
+
*
|
|
81
|
+
* See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/gap
|
|
82
|
+
*/
|
|
83
|
+
gap?: Spaces | Gap;
|
|
84
|
+
/**
|
|
85
|
+
* Sets the place-content CSS property.
|
|
86
|
+
*
|
|
87
|
+
* See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/place-content
|
|
88
|
+
*/
|
|
89
|
+
placeContent?: PlaceGeneric<PlaceContentValues, "content">;
|
|
90
|
+
/**
|
|
91
|
+
* Sets the place-items CSS property.
|
|
92
|
+
*
|
|
93
|
+
* See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/place-items
|
|
94
|
+
*/
|
|
95
|
+
placeItems?: PlaceGeneric<PlaceItemsValues, "items">;
|
|
96
|
+
/**
|
|
97
|
+
* Sets the grid-template-areas CSS property.
|
|
98
|
+
*
|
|
99
|
+
* See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas
|
|
100
|
+
*/
|
|
101
|
+
templateAreas?: string[];
|
|
102
|
+
/**
|
|
103
|
+
* Sets the grid-template-columns CSS property.
|
|
104
|
+
*
|
|
105
|
+
* See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns
|
|
106
|
+
*/
|
|
107
|
+
templateColumns?: string[];
|
|
108
|
+
/**
|
|
109
|
+
* Sets the grid-template-rows CSS property.
|
|
110
|
+
*
|
|
111
|
+
* See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows
|
|
112
|
+
*/
|
|
113
|
+
templateRows?: string[];
|
|
114
|
+
};
|
|
115
|
+
export default Props;
|
package/grid/types.js
ADDED
package/inset/Inset.stories.tsx
CHANGED
|
@@ -9,9 +9,9 @@ declare const DxcApplicationLayout: {
|
|
|
9
9
|
Main: ({ children }: AppLayoutMainPropsType) => JSX.Element;
|
|
10
10
|
Footer: ({ socialLinks, bottomLinks, copyright, children, padding, margin, tabIndex, }: import("../footer/types").default) => JSX.Element;
|
|
11
11
|
SideNav: {
|
|
12
|
-
({
|
|
12
|
+
({ title, children }: import("../sidenav/types").default): JSX.Element;
|
|
13
13
|
Section: ({ children }: import("../sidenav/types").SidenavSectionPropsType) => JSX.Element;
|
|
14
|
-
Group: ({
|
|
14
|
+
Group: ({ title, collapsable, icon, children }: import("../sidenav/types").SidenavGroupPropsType) => JSX.Element;
|
|
15
15
|
Link: React.ForwardRefExoticComponent<import("../sidenav/types").SidenavLinkPropsType & React.RefAttributes<HTMLAnchorElement>>;
|
|
16
16
|
Title: ({ children }: import("../sidenav/types").SidenavTitlePropsType) => JSX.Element;
|
|
17
17
|
};
|
package/layout/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare type ChildrenType = AppLayoutMainPropsType | AppLayoutSidenavPropsType;
|
|
3
2
|
export declare type AppLayoutMainPropsType = {
|
|
4
3
|
/**
|
|
5
4
|
* Everything between the tags will be displayed as the content of the main part of the application.
|
|
@@ -35,8 +34,8 @@ declare type AppLayoutPropsType = {
|
|
|
35
34
|
*/
|
|
36
35
|
footer?: React.ReactNode;
|
|
37
36
|
/**
|
|
38
|
-
*
|
|
37
|
+
* Use the DxcApplicationLayout.Main provided to render main content.
|
|
39
38
|
*/
|
|
40
|
-
children: React.ReactElement<
|
|
39
|
+
children: React.ReactElement<AppLayoutMainPropsType>;
|
|
41
40
|
};
|
|
42
41
|
export default AppLayoutPropsType;
|
package/main.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ import DxcFlex from "./flex/Flex";
|
|
|
39
39
|
import DxcTypography from "./typography/Typography";
|
|
40
40
|
import DxcParagraph from "./paragraph/Paragraph";
|
|
41
41
|
import DxcBulletedList from "./bulleted-list/BulletedList";
|
|
42
|
+
import DxcGrid from "./grid/Grid";
|
|
42
43
|
import HalstackContext, { HalstackProvider, HalstackLanguageContext } from "./HalstackContext";
|
|
43
44
|
import { BackgroundColorProvider } from "./BackgroundColorContext";
|
|
44
|
-
export { DxcAlert, DxcButton, DxcCheckbox, DxcTextInput, DxcDropdown, DxcSwitch, DxcSlider, DxcTable, DxcTabs, DxcToggleGroup, DxcDialog, DxcCard, DxcProgressBar, DxcAccordion, DxcSpinner, DxcBox, DxcTag, DxcPaginator, DxcWizard, DxcLink, DxcHeading, DxcResultsetTable, DxcChip, DxcApplicationLayout, HalstackContext, HalstackLanguageContext, HalstackProvider, BackgroundColorProvider, DxcAccordionGroup, DxcBadge, DxcPasswordInput, DxcDateInput, DxcNumberInput, DxcTextarea, DxcSelect, DxcFileInput, DxcRadioGroup, DxcBleed, DxcInset, DxcQuickNav, DxcNavTabs, DxcFlex, DxcTypography, DxcParagraph, DxcBulletedList, };
|
|
45
|
+
export { DxcAlert, DxcButton, DxcCheckbox, DxcTextInput, DxcDropdown, DxcSwitch, DxcSlider, DxcTable, DxcTabs, DxcToggleGroup, DxcDialog, DxcCard, DxcProgressBar, DxcAccordion, DxcSpinner, DxcBox, DxcTag, DxcPaginator, DxcWizard, DxcLink, DxcHeading, DxcResultsetTable, DxcChip, DxcApplicationLayout, HalstackContext, HalstackLanguageContext, HalstackProvider, BackgroundColorProvider, DxcAccordionGroup, DxcBadge, DxcPasswordInput, DxcDateInput, DxcNumberInput, DxcTextarea, DxcSelect, DxcFileInput, DxcRadioGroup, DxcBleed, DxcInset, DxcQuickNav, DxcNavTabs, DxcFlex, DxcTypography, DxcParagraph, DxcBulletedList, DxcGrid, };
|