carbon-react 142.4.1 → 142.5.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/esm/components/tile/tile.component.d.ts +5 -1
- package/esm/components/tile/tile.component.js +12 -2
- package/esm/components/tile/tile.config.d.ts +1 -0
- package/esm/components/tile/tile.config.js +2 -1
- package/esm/components/tile/tile.style.d.ts +5 -1
- package/esm/components/tile/tile.style.js +37 -2
- package/lib/components/tile/tile.component.d.ts +5 -1
- package/lib/components/tile/tile.component.js +14 -2
- package/lib/components/tile/tile.config.d.ts +1 -0
- package/lib/components/tile/tile.config.js +3 -2
- package/lib/components/tile/tile.style.d.ts +5 -1
- package/lib/components/tile/tile.style.js +38 -3
- package/package.json +1 -1
|
@@ -2,7 +2,9 @@ import React from "react";
|
|
|
2
2
|
import * as DesignTokens from "@sage/design-tokens/js/base/common";
|
|
3
3
|
import { SpaceProps, WidthProps } from "styled-system";
|
|
4
4
|
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
5
|
+
import { TILE_HIGHLIGHT_VARIANTS } from "./tile.config";
|
|
5
6
|
declare type DesignTokensType = keyof typeof DesignTokens;
|
|
7
|
+
declare type HighlightVariantType = typeof TILE_HIGHLIGHT_VARIANTS[number];
|
|
6
8
|
export interface TileProps extends SpaceProps, WidthProps, TagProps {
|
|
7
9
|
/** Sets the theme of the tile */
|
|
8
10
|
variant?: "tile" | "transparent" | "active" | "grey";
|
|
@@ -31,6 +33,8 @@ export interface TileProps extends SpaceProps, WidthProps, TagProps {
|
|
|
31
33
|
* Set a percentage-based height for the whole Tile component, relative to its parent.
|
|
32
34
|
*/
|
|
33
35
|
height?: string | number;
|
|
36
|
+
/** Sets the highlight variant */
|
|
37
|
+
highlightVariant?: HighlightVariantType;
|
|
34
38
|
}
|
|
35
|
-
export declare const Tile: ({ variant, p, children, orientation, width, roundness, height, borderWidth, borderVariant, ...rest }: TileProps) => React.JSX.Element;
|
|
39
|
+
export declare const Tile: ({ variant, p, children, orientation, width, roundness, height, borderWidth, borderVariant, highlightVariant, ...rest }: TileProps) => React.JSX.Element;
|
|
36
40
|
export default Tile;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
2
|
import React from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
-
import StyledTile from "./tile.style";
|
|
4
|
+
import StyledTile, { StyledHighlight } from "./tile.style";
|
|
5
5
|
import TileContext from "./__internal__/tile.context";
|
|
6
6
|
import filterStyledSystemPaddingProps from "../../style/utils/filter-styled-system-padding-props";
|
|
7
7
|
import filterStyledSystemMarginProps from "../../style/utils/filter-styled-system-margin-props";
|
|
@@ -17,6 +17,7 @@ export const Tile = ({
|
|
|
17
17
|
height,
|
|
18
18
|
borderWidth,
|
|
19
19
|
borderVariant,
|
|
20
|
+
highlightVariant,
|
|
20
21
|
...rest
|
|
21
22
|
}) => {
|
|
22
23
|
const isHorizontal = orientation === "horizontal";
|
|
@@ -26,7 +27,7 @@ export const Tile = ({
|
|
|
26
27
|
});
|
|
27
28
|
const marginProps = filterStyledSystemMarginProps(rest);
|
|
28
29
|
const contentPaddingProps = computeContentPadding(paddingProps, isHorizontal);
|
|
29
|
-
|
|
30
|
+
const tile = /*#__PURE__*/React.createElement(StyledTile, _extends({
|
|
30
31
|
variant: variant,
|
|
31
32
|
width: width,
|
|
32
33
|
height: height,
|
|
@@ -41,5 +42,14 @@ export const Tile = ({
|
|
|
41
42
|
paddingPropsFromTile: contentPaddingProps
|
|
42
43
|
}
|
|
43
44
|
}, children));
|
|
45
|
+
if (highlightVariant) {
|
|
46
|
+
return /*#__PURE__*/React.createElement(StyledHighlight, {
|
|
47
|
+
variant: highlightVariant,
|
|
48
|
+
roundness: roundness,
|
|
49
|
+
"aria-hidden": true,
|
|
50
|
+
"data-role": `tile-${highlightVariant}-highlight`
|
|
51
|
+
}, tile);
|
|
52
|
+
}
|
|
53
|
+
return tile;
|
|
44
54
|
};
|
|
45
55
|
export default Tile;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export const TILE_ORIENTATIONS = ["horizontal", "vertical"];
|
|
2
2
|
export const TILE_THEMES = ["tile", "transparent", "active", "grey"];
|
|
3
|
-
export const TILE_BORDER_VARIANTS = ["default", "info", "selected", "negative", "positive", "caution"];
|
|
3
|
+
export const TILE_BORDER_VARIANTS = ["default", "info", "selected", "negative", "positive", "caution"];
|
|
4
|
+
export const TILE_HIGHLIGHT_VARIANTS = ["gradient", "success", "neutral", "error", "warning", "info"];
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { SpaceProps } from "styled-system";
|
|
2
2
|
import { TileProps } from "./tile.component";
|
|
3
|
-
declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "height" | "variant" | "roundness" | "borderWidth" | "borderVariant"> & {
|
|
3
|
+
declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "height" | "variant" | "roundness" | "borderWidth" | "borderVariant" | "highlightVariant"> & {
|
|
4
4
|
isHorizontal?: boolean | undefined;
|
|
5
5
|
} & SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol>, never>;
|
|
6
|
+
export declare const StyledHighlight: import("styled-components").StyledComponent<"div", any, {
|
|
7
|
+
variant: Required<TileProps["highlightVariant"]>;
|
|
8
|
+
roundness: TileProps["roundness"];
|
|
9
|
+
}, never>;
|
|
6
10
|
export default StyledTile;
|
|
@@ -2,6 +2,7 @@ import styled, { css } from "styled-components";
|
|
|
2
2
|
import { space } from "styled-system";
|
|
3
3
|
import baseTheme from "../../style/themes/base";
|
|
4
4
|
import computeSizing from "../../style/utils/element-sizing";
|
|
5
|
+
import StyledTileContent from "./tile-content/tile-content.style";
|
|
5
6
|
const getBorderColor = (borderVariant, variant) => {
|
|
6
7
|
switch (borderVariant) {
|
|
7
8
|
case "selected":
|
|
@@ -35,6 +36,23 @@ const getBorderRadius = roundness => {
|
|
|
35
36
|
return "var(--borderRadius100)";
|
|
36
37
|
}
|
|
37
38
|
};
|
|
39
|
+
const getHeighlightVariant = variant => {
|
|
40
|
+
switch (variant) {
|
|
41
|
+
case "success":
|
|
42
|
+
return "var(--colorsSemanticPositive500)";
|
|
43
|
+
case "neutral":
|
|
44
|
+
return "var(--colorsSemanticNeutral500)";
|
|
45
|
+
case "error":
|
|
46
|
+
return "var(--colorsSemanticNegative500)";
|
|
47
|
+
case "warning":
|
|
48
|
+
return "var(--colorsSemanticCaution500)";
|
|
49
|
+
case "info":
|
|
50
|
+
return "var(--colorsSemanticInfo500)";
|
|
51
|
+
default:
|
|
52
|
+
// gradient is default
|
|
53
|
+
return "linear-gradient(0deg, rgb(143, 73, 254) 5%, rgb(0, 146, 219) 50%, rgb(19, 160, 56) 95%)";
|
|
54
|
+
}
|
|
55
|
+
};
|
|
38
56
|
const StyledTile = styled.div`
|
|
39
57
|
${({
|
|
40
58
|
borderVariant,
|
|
@@ -53,12 +71,12 @@ const StyledTile = styled.div`
|
|
|
53
71
|
border-radius: ${getBorderRadius(roundness)};
|
|
54
72
|
--tileBorderRadius: ${getBorderRadius(roundness)};
|
|
55
73
|
|
|
56
|
-
> *:first-child {
|
|
74
|
+
> *:first-child:not(${StyledTileContent}) {
|
|
57
75
|
border-top-left-radius: calc(${getBorderRadius(roundness)} - 1px);
|
|
58
76
|
border-top-right-radius: calc(${getBorderRadius(roundness)} - 1px);
|
|
59
77
|
}
|
|
60
78
|
|
|
61
|
-
> *:last-child {
|
|
79
|
+
> *:last-child:not(${StyledTileContent}) {
|
|
62
80
|
border-bottom-left-radius: calc(${getBorderRadius(roundness)} - 1px);
|
|
63
81
|
border-bottom-right-radius: calc(${getBorderRadius(roundness)} - 1px);
|
|
64
82
|
}
|
|
@@ -91,4 +109,21 @@ const StyledTile = styled.div`
|
|
|
91
109
|
StyledTile.defaultProps = {
|
|
92
110
|
theme: baseTheme
|
|
93
111
|
};
|
|
112
|
+
export const StyledHighlight = styled.div`
|
|
113
|
+
height: 100%;
|
|
114
|
+
width: 100%;
|
|
115
|
+
position: relative;
|
|
116
|
+
background: ${({
|
|
117
|
+
variant
|
|
118
|
+
}) => getHeighlightVariant(variant)};
|
|
119
|
+
border-radius: ${({
|
|
120
|
+
roundness
|
|
121
|
+
}) => getBorderRadius(roundness)};
|
|
122
|
+
|
|
123
|
+
${StyledTile} {
|
|
124
|
+
border-left: 0;
|
|
125
|
+
left: 4px;
|
|
126
|
+
width: calc(100% - 4px);
|
|
127
|
+
}
|
|
128
|
+
`;
|
|
94
129
|
export default StyledTile;
|
|
@@ -2,7 +2,9 @@ import React from "react";
|
|
|
2
2
|
import * as DesignTokens from "@sage/design-tokens/js/base/common";
|
|
3
3
|
import { SpaceProps, WidthProps } from "styled-system";
|
|
4
4
|
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
5
|
+
import { TILE_HIGHLIGHT_VARIANTS } from "./tile.config";
|
|
5
6
|
declare type DesignTokensType = keyof typeof DesignTokens;
|
|
7
|
+
declare type HighlightVariantType = typeof TILE_HIGHLIGHT_VARIANTS[number];
|
|
6
8
|
export interface TileProps extends SpaceProps, WidthProps, TagProps {
|
|
7
9
|
/** Sets the theme of the tile */
|
|
8
10
|
variant?: "tile" | "transparent" | "active" | "grey";
|
|
@@ -31,6 +33,8 @@ export interface TileProps extends SpaceProps, WidthProps, TagProps {
|
|
|
31
33
|
* Set a percentage-based height for the whole Tile component, relative to its parent.
|
|
32
34
|
*/
|
|
33
35
|
height?: string | number;
|
|
36
|
+
/** Sets the highlight variant */
|
|
37
|
+
highlightVariant?: HighlightVariantType;
|
|
34
38
|
}
|
|
35
|
-
export declare const Tile: ({ variant, p, children, orientation, width, roundness, height, borderWidth, borderVariant, ...rest }: TileProps) => React.JSX.Element;
|
|
39
|
+
export declare const Tile: ({ variant, p, children, orientation, width, roundness, height, borderWidth, borderVariant, highlightVariant, ...rest }: TileProps) => React.JSX.Element;
|
|
36
40
|
export default Tile;
|
|
@@ -6,12 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = exports.Tile = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var _tile =
|
|
9
|
+
var _tile = _interopRequireWildcard(require("./tile.style"));
|
|
10
10
|
var _tile2 = _interopRequireDefault(require("./__internal__/tile.context"));
|
|
11
11
|
var _filterStyledSystemPaddingProps = _interopRequireDefault(require("../../style/utils/filter-styled-system-padding-props"));
|
|
12
12
|
var _filterStyledSystemMarginProps = _interopRequireDefault(require("../../style/utils/filter-styled-system-margin-props"));
|
|
13
13
|
var _computeContentPadding = _interopRequireDefault(require("./__internal__/compute-content-padding"));
|
|
14
14
|
var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags"));
|
|
15
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
18
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
17
19
|
const Tile = ({
|
|
@@ -24,6 +26,7 @@ const Tile = ({
|
|
|
24
26
|
height,
|
|
25
27
|
borderWidth,
|
|
26
28
|
borderVariant,
|
|
29
|
+
highlightVariant,
|
|
27
30
|
...rest
|
|
28
31
|
}) => {
|
|
29
32
|
const isHorizontal = orientation === "horizontal";
|
|
@@ -33,7 +36,7 @@ const Tile = ({
|
|
|
33
36
|
});
|
|
34
37
|
const marginProps = (0, _filterStyledSystemMarginProps.default)(rest);
|
|
35
38
|
const contentPaddingProps = (0, _computeContentPadding.default)(paddingProps, isHorizontal);
|
|
36
|
-
|
|
39
|
+
const tile = /*#__PURE__*/_react.default.createElement(_tile.default, _extends({
|
|
37
40
|
variant: variant,
|
|
38
41
|
width: width,
|
|
39
42
|
height: height,
|
|
@@ -48,6 +51,15 @@ const Tile = ({
|
|
|
48
51
|
paddingPropsFromTile: contentPaddingProps
|
|
49
52
|
}
|
|
50
53
|
}, children));
|
|
54
|
+
if (highlightVariant) {
|
|
55
|
+
return /*#__PURE__*/_react.default.createElement(_tile.StyledHighlight, {
|
|
56
|
+
variant: highlightVariant,
|
|
57
|
+
roundness: roundness,
|
|
58
|
+
"aria-hidden": true,
|
|
59
|
+
"data-role": `tile-${highlightVariant}-highlight`
|
|
60
|
+
}, tile);
|
|
61
|
+
}
|
|
62
|
+
return tile;
|
|
51
63
|
};
|
|
52
64
|
exports.Tile = Tile;
|
|
53
65
|
var _default = exports.default = Tile;
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TILE_THEMES = exports.TILE_ORIENTATIONS = exports.TILE_BORDER_VARIANTS = void 0;
|
|
6
|
+
exports.TILE_THEMES = exports.TILE_ORIENTATIONS = exports.TILE_HIGHLIGHT_VARIANTS = exports.TILE_BORDER_VARIANTS = void 0;
|
|
7
7
|
const TILE_ORIENTATIONS = exports.TILE_ORIENTATIONS = ["horizontal", "vertical"];
|
|
8
8
|
const TILE_THEMES = exports.TILE_THEMES = ["tile", "transparent", "active", "grey"];
|
|
9
|
-
const TILE_BORDER_VARIANTS = exports.TILE_BORDER_VARIANTS = ["default", "info", "selected", "negative", "positive", "caution"];
|
|
9
|
+
const TILE_BORDER_VARIANTS = exports.TILE_BORDER_VARIANTS = ["default", "info", "selected", "negative", "positive", "caution"];
|
|
10
|
+
const TILE_HIGHLIGHT_VARIANTS = exports.TILE_HIGHLIGHT_VARIANTS = ["gradient", "success", "neutral", "error", "warning", "info"];
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { SpaceProps } from "styled-system";
|
|
2
2
|
import { TileProps } from "./tile.component";
|
|
3
|
-
declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "height" | "variant" | "roundness" | "borderWidth" | "borderVariant"> & {
|
|
3
|
+
declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "height" | "variant" | "roundness" | "borderWidth" | "borderVariant" | "highlightVariant"> & {
|
|
4
4
|
isHorizontal?: boolean | undefined;
|
|
5
5
|
} & SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol>, never>;
|
|
6
|
+
export declare const StyledHighlight: import("styled-components").StyledComponent<"div", any, {
|
|
7
|
+
variant: Required<TileProps["highlightVariant"]>;
|
|
8
|
+
roundness: TileProps["roundness"];
|
|
9
|
+
}, never>;
|
|
6
10
|
export default StyledTile;
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.default = exports.StyledHighlight = void 0;
|
|
7
7
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
8
|
var _styledSystem = require("styled-system");
|
|
9
9
|
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
10
10
|
var _elementSizing = _interopRequireDefault(require("../../style/utils/element-sizing"));
|
|
11
|
+
var _tileContent = _interopRequireDefault(require("./tile-content/tile-content.style"));
|
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -44,6 +45,23 @@ const getBorderRadius = roundness => {
|
|
|
44
45
|
return "var(--borderRadius100)";
|
|
45
46
|
}
|
|
46
47
|
};
|
|
48
|
+
const getHeighlightVariant = variant => {
|
|
49
|
+
switch (variant) {
|
|
50
|
+
case "success":
|
|
51
|
+
return "var(--colorsSemanticPositive500)";
|
|
52
|
+
case "neutral":
|
|
53
|
+
return "var(--colorsSemanticNeutral500)";
|
|
54
|
+
case "error":
|
|
55
|
+
return "var(--colorsSemanticNegative500)";
|
|
56
|
+
case "warning":
|
|
57
|
+
return "var(--colorsSemanticCaution500)";
|
|
58
|
+
case "info":
|
|
59
|
+
return "var(--colorsSemanticInfo500)";
|
|
60
|
+
default:
|
|
61
|
+
// gradient is default
|
|
62
|
+
return "linear-gradient(0deg, rgb(143, 73, 254) 5%, rgb(0, 146, 219) 50%, rgb(19, 160, 56) 95%)";
|
|
63
|
+
}
|
|
64
|
+
};
|
|
47
65
|
const StyledTile = _styledComponents.default.div`
|
|
48
66
|
${({
|
|
49
67
|
borderVariant,
|
|
@@ -62,12 +80,12 @@ const StyledTile = _styledComponents.default.div`
|
|
|
62
80
|
border-radius: ${getBorderRadius(roundness)};
|
|
63
81
|
--tileBorderRadius: ${getBorderRadius(roundness)};
|
|
64
82
|
|
|
65
|
-
> *:first-child {
|
|
83
|
+
> *:first-child:not(${_tileContent.default}) {
|
|
66
84
|
border-top-left-radius: calc(${getBorderRadius(roundness)} - 1px);
|
|
67
85
|
border-top-right-radius: calc(${getBorderRadius(roundness)} - 1px);
|
|
68
86
|
}
|
|
69
87
|
|
|
70
|
-
> *:last-child {
|
|
88
|
+
> *:last-child:not(${_tileContent.default}) {
|
|
71
89
|
border-bottom-left-radius: calc(${getBorderRadius(roundness)} - 1px);
|
|
72
90
|
border-bottom-right-radius: calc(${getBorderRadius(roundness)} - 1px);
|
|
73
91
|
}
|
|
@@ -100,4 +118,21 @@ const StyledTile = _styledComponents.default.div`
|
|
|
100
118
|
StyledTile.defaultProps = {
|
|
101
119
|
theme: _base.default
|
|
102
120
|
};
|
|
121
|
+
const StyledHighlight = exports.StyledHighlight = _styledComponents.default.div`
|
|
122
|
+
height: 100%;
|
|
123
|
+
width: 100%;
|
|
124
|
+
position: relative;
|
|
125
|
+
background: ${({
|
|
126
|
+
variant
|
|
127
|
+
}) => getHeighlightVariant(variant)};
|
|
128
|
+
border-radius: ${({
|
|
129
|
+
roundness
|
|
130
|
+
}) => getBorderRadius(roundness)};
|
|
131
|
+
|
|
132
|
+
${StyledTile} {
|
|
133
|
+
border-left: 0;
|
|
134
|
+
left: 4px;
|
|
135
|
+
width: calc(100% - 4px);
|
|
136
|
+
}
|
|
137
|
+
`;
|
|
103
138
|
var _default = exports.default = StyledTile;
|