@uni-design-system/uni-react 0.0.18 → 0.0.19
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/cjs/components/button/button.component.js +1 -1
- package/dist/cjs/components/card/card.component.js +2 -1
- package/dist/cjs/components/grainy-gradient-background/grainy-gradient-background.component.d.ts +13 -0
- package/dist/cjs/components/grainy-gradient-background/grainy-gradient-background.component.js +42 -0
- package/dist/cjs/components/icon-text-row/icon-text-row.component.js +1 -1
- package/dist/cjs/core/container/container.component.d.ts +7 -2
- package/dist/cjs/core/container/container.component.js +29 -6
- package/dist/cjs/core/text/text.component.d.ts +1 -1
- package/dist/cjs/core/text/text.component.js +34 -14
- package/dist/esm/components/button/button.component.js +1 -1
- package/dist/esm/components/card/card.component.js +2 -1
- package/dist/esm/components/grainy-gradient-background/grainy-gradient-background.component.d.ts +13 -0
- package/dist/esm/components/grainy-gradient-background/grainy-gradient-background.component.js +35 -0
- package/dist/esm/components/icon-text-row/icon-text-row.component.js +1 -1
- package/dist/esm/core/container/container.component.d.ts +7 -2
- package/dist/esm/core/container/container.component.js +5 -3
- package/dist/esm/core/text/text.component.d.ts +1 -1
- package/dist/esm/core/text/text.component.js +11 -11
- package/package.json +1 -1
|
@@ -62,7 +62,7 @@ const Button = (_a) => {
|
|
|
62
62
|
setClick(true);
|
|
63
63
|
onClick && onClick(event);
|
|
64
64
|
};
|
|
65
|
-
return (react_1.default.createElement("button", Object.assign({ onMouseDown: createRipple, onMouseEnter: () => setHover(true), onMouseLeave: () => setHover(false), onClick: handleClick, disabled: disabled, style: Object.assign(Object.assign({}, style), userStyle), ref: ref }, rest), iconName ? (react_1.default.createElement(icon_text_row_1.IconTextRow, { iconName: iconName, color: contentColor, textRole: "button" }, text || children)) : (react_1.default.createElement(core_1.Text, { align: "center", role: "button",
|
|
65
|
+
return (react_1.default.createElement("button", Object.assign({ onMouseDown: createRipple, onMouseEnter: () => setHover(true), onMouseLeave: () => setHover(false), onClick: handleClick, disabled: disabled, style: Object.assign(Object.assign({}, style), userStyle), ref: ref }, rest), iconName ? (react_1.default.createElement(icon_text_row_1.IconTextRow, { iconName: iconName, color: contentColor, textRole: "button" }, text || children)) : (react_1.default.createElement(core_1.Text, { align: "center", role: "button", colorToken: contentColor }, text || children))));
|
|
66
66
|
};
|
|
67
67
|
exports.Button = Button;
|
|
68
68
|
function Style(theme, buttonType, size = 'md', hover, disabled, click) {
|
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.Card = void 0;
|
|
18
18
|
const react_1 = __importDefault(require("react"));
|
|
19
19
|
const core_1 = require("../../core");
|
|
20
|
+
const container_component_1 = __importDefault(require("../../core/container/container.component"));
|
|
20
21
|
function Card(_a) {
|
|
21
22
|
var { children, cardType, elevation, colorToken = 'surface', width, height, borderRadius, style } = _a, rest = __rest(_a, ["children", "cardType", "elevation", "colorToken", "width", "height", "borderRadius", "style"]);
|
|
22
23
|
const { colors, containers } = (0, core_1.useTheme)();
|
|
@@ -29,6 +30,6 @@ function Card(_a) {
|
|
|
29
30
|
if (borderRadii && borderRadius !== 'none') {
|
|
30
31
|
styles.borderRadius = borderRadii[borderRadius || 'md'];
|
|
31
32
|
}
|
|
32
|
-
return (react_1.default.createElement(
|
|
33
|
+
return (react_1.default.createElement(container_component_1.default, Object.assign({ colorToken: colorToken, style: styles }, rest), children));
|
|
33
34
|
}
|
|
34
35
|
exports.Card = Card;
|
package/dist/cjs/components/grainy-gradient-background/grainy-gradient-background.component.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Property } from 'csstype';
|
|
3
|
+
export interface GrainyGradientProps {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
noiseFrequency?: number;
|
|
6
|
+
noiseOctaves?: number;
|
|
7
|
+
size?: number;
|
|
8
|
+
minHeight?: Property.MinHeight;
|
|
9
|
+
angle?: number;
|
|
10
|
+
gradientColor?: Property.Color;
|
|
11
|
+
backgroundColor?: Property.Color;
|
|
12
|
+
}
|
|
13
|
+
export declare const GrainyGradientBackground: ({ children, noiseFrequency, noiseOctaves, minHeight, size, angle, gradientColor, backgroundColor, }: GrainyGradientProps) => JSX.Element;
|
package/dist/cjs/components/grainy-gradient-background/grainy-gradient-background.component.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.GrainyGradientBackground = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const GrainyGradientBackground = ({ children, noiseFrequency = 0.65, noiseOctaves = 3, minHeight, size = 740, angle = 20, gradientColor = 'rebeccapurple', backgroundColor = 'moccasin', }) => {
|
|
9
|
+
const gradient = `linear-gradient(${angle}deg, ${gradientColor}, transparent)`;
|
|
10
|
+
const image = `url("data:image/svg+xml,%3Csvg viewBox='0 0 ${size} ${size}' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='${noiseFrequency}' numOctaves='${noiseOctaves}' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E")`;
|
|
11
|
+
const container = {};
|
|
12
|
+
const content = {
|
|
13
|
+
position: 'absolute',
|
|
14
|
+
width: '100%',
|
|
15
|
+
height: '100%',
|
|
16
|
+
};
|
|
17
|
+
const noise = {
|
|
18
|
+
filter: 'contrast(290%) brightness(1000%)',
|
|
19
|
+
background: gradient + ', ' + image,
|
|
20
|
+
minHeight,
|
|
21
|
+
};
|
|
22
|
+
const isolate = {
|
|
23
|
+
isolation: 'isolate',
|
|
24
|
+
position: 'absolute',
|
|
25
|
+
width: '100%',
|
|
26
|
+
height: '100%',
|
|
27
|
+
};
|
|
28
|
+
const overlay = {
|
|
29
|
+
position: 'absolute',
|
|
30
|
+
top: 0,
|
|
31
|
+
width: '100%',
|
|
32
|
+
height: '100%',
|
|
33
|
+
background: backgroundColor,
|
|
34
|
+
mixBlendMode: 'multiply',
|
|
35
|
+
};
|
|
36
|
+
return (react_1.default.createElement("div", { style: container },
|
|
37
|
+
react_1.default.createElement("div", { style: isolate },
|
|
38
|
+
react_1.default.createElement("div", { style: noise }),
|
|
39
|
+
react_1.default.createElement("div", { style: overlay })),
|
|
40
|
+
react_1.default.createElement("div", { style: content }, children)));
|
|
41
|
+
};
|
|
42
|
+
exports.GrainyGradientBackground = GrainyGradientBackground;
|
|
@@ -19,7 +19,7 @@ const IconTextRow = ({ iconName, color, align = 'left', text, textRole = 'title-
|
|
|
19
19
|
}
|
|
20
20
|
function RowText() {
|
|
21
21
|
return (react_1.default.createElement("div", { style: Object.assign(Object.assign({}, core_1.expand), { paddingLeft: textMargin, paddingRight: textMargin }) },
|
|
22
|
-
react_1.default.createElement(core_1.Text, { align: align,
|
|
22
|
+
react_1.default.createElement(core_1.Text, { align: align, colorToken: color, role: textRole }, text || children)));
|
|
23
23
|
}
|
|
24
24
|
function RowCenter() {
|
|
25
25
|
return align === 'center' ? react_1.default.createElement("div", { style: Object.assign({}, core_1.expand) }) : null;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { CSSProperties, ReactNode } from 'react';
|
|
1
|
+
import React, { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import { ContainerColorToken } from '@uni-design-system/uni-core';
|
|
2
3
|
export interface ContainerProps {
|
|
3
4
|
children: ReactNode;
|
|
4
5
|
style: CSSProperties;
|
|
6
|
+
colorToken?: ContainerColorToken;
|
|
5
7
|
}
|
|
6
|
-
export
|
|
8
|
+
export declare const ContainerContext: React.Context<{
|
|
9
|
+
colorToken?: ContainerColorToken | undefined;
|
|
10
|
+
}>;
|
|
11
|
+
export default function Container({ children, style, colorToken, ...rest }: ContainerProps): JSX.Element;
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
26
|
var t = {};
|
|
4
27
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -10,13 +33,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
33
|
}
|
|
11
34
|
return t;
|
|
12
35
|
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
37
|
+
exports.ContainerContext = void 0;
|
|
38
|
+
const react_1 = __importStar(require("react"));
|
|
39
|
+
exports.ContainerContext = (0, react_1.createContext)({});
|
|
18
40
|
function Container(_a) {
|
|
19
|
-
var { children, style } = _a, rest = __rest(_a, ["children", "style"]);
|
|
20
|
-
return (react_1.default.createElement(
|
|
41
|
+
var { children, style, colorToken } = _a, rest = __rest(_a, ["children", "style", "colorToken"]);
|
|
42
|
+
return (react_1.default.createElement(exports.ContainerContext.Provider, { value: { colorToken } },
|
|
43
|
+
react_1.default.createElement("div", Object.assign({ style: style }, rest), children)));
|
|
21
44
|
}
|
|
22
45
|
exports.default = Container;
|
|
@@ -1,30 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
exports.Text = void 0;
|
|
7
|
-
const react_1 =
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
8
28
|
const uni_core_1 = require("@uni-design-system/uni-core");
|
|
9
29
|
const theme_1 = require("../theme");
|
|
30
|
+
const container_1 = require("../container");
|
|
10
31
|
function Text(props) {
|
|
11
|
-
const { text, children, align, role = 'body-1-long',
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const { fontSize, letterSpacing, lineHeight, fontWeight, fontFamily, fontStyle, textTransform } = theme.typography[role];
|
|
19
|
-
return {
|
|
20
|
-
color: theme.colors[color || 'on-background'],
|
|
32
|
+
const { text, children, align, role = 'body-1-long', colorToken: overridingColorToken } = props;
|
|
33
|
+
const { colors, typography } = (0, theme_1.useTheme)();
|
|
34
|
+
const { colorToken: containerColorToken } = (0, react_1.useContext)(container_1.ContainerContext);
|
|
35
|
+
const colorToken = containerColorToken ? `on-${containerColorToken}` : undefined;
|
|
36
|
+
const { fontSize, letterSpacing, lineHeight, fontWeight, fontFamily, fontStyle, textTransform } = typography[role];
|
|
37
|
+
const style = {
|
|
38
|
+
color: colors[overridingColorToken || colorToken || 'on-surface'],
|
|
21
39
|
fontSize: fontSize + 'px',
|
|
22
40
|
letterSpacing,
|
|
23
|
-
textAlign,
|
|
41
|
+
textAlign: align,
|
|
24
42
|
textTransform,
|
|
25
43
|
lineHeight: lineHeight + 'px',
|
|
26
44
|
fontFamily,
|
|
27
45
|
fontStyle,
|
|
28
46
|
fontWeight: uni_core_1.FontWeightMap[fontWeight],
|
|
29
47
|
};
|
|
48
|
+
return react_1.default.createElement("div", { style: style }, text || children);
|
|
30
49
|
}
|
|
50
|
+
exports.Text = Text;
|
|
@@ -33,7 +33,7 @@ export const Button = (_a) => {
|
|
|
33
33
|
setClick(true);
|
|
34
34
|
onClick && onClick(event);
|
|
35
35
|
};
|
|
36
|
-
return (React.createElement("button", Object.assign({ onMouseDown: createRipple, onMouseEnter: () => setHover(true), onMouseLeave: () => setHover(false), onClick: handleClick, disabled: disabled, style: Object.assign(Object.assign({}, style), userStyle), ref: ref }, rest), iconName ? (React.createElement(IconTextRow, { iconName: iconName, color: contentColor, textRole: "button" }, text || children)) : (React.createElement(Text, { align: "center", role: "button",
|
|
36
|
+
return (React.createElement("button", Object.assign({ onMouseDown: createRipple, onMouseEnter: () => setHover(true), onMouseLeave: () => setHover(false), onClick: handleClick, disabled: disabled, style: Object.assign(Object.assign({}, style), userStyle), ref: ref }, rest), iconName ? (React.createElement(IconTextRow, { iconName: iconName, color: contentColor, textRole: "button" }, text || children)) : (React.createElement(Text, { align: "center", role: "button", colorToken: contentColor }, text || children))));
|
|
37
37
|
};
|
|
38
38
|
function Style(theme, buttonType, size = 'md', hover, disabled, click) {
|
|
39
39
|
const { color, horizontalPadding, verticalPadding, borderColor, borderWidth, borderRadius, contentColor } = theme.buttons[buttonType];
|
|
@@ -11,6 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import React from 'react';
|
|
13
13
|
import { BoxShadow, Padding, useTheme } from '../../core';
|
|
14
|
+
import Container from '../../core/container/container.component';
|
|
14
15
|
export function Card(_a) {
|
|
15
16
|
var { children, cardType, elevation, colorToken = 'surface', width, height, borderRadius, style } = _a, rest = __rest(_a, ["children", "cardType", "elevation", "colorToken", "width", "height", "borderRadius", "style"]);
|
|
16
17
|
const { colors, containers } = useTheme();
|
|
@@ -23,5 +24,5 @@ export function Card(_a) {
|
|
|
23
24
|
if (borderRadii && borderRadius !== 'none') {
|
|
24
25
|
styles.borderRadius = borderRadii[borderRadius || 'md'];
|
|
25
26
|
}
|
|
26
|
-
return (React.createElement(
|
|
27
|
+
return (React.createElement(Container, Object.assign({ colorToken: colorToken, style: styles }, rest), children));
|
|
27
28
|
}
|
package/dist/esm/components/grainy-gradient-background/grainy-gradient-background.component.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Property } from 'csstype';
|
|
3
|
+
export interface GrainyGradientProps {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
noiseFrequency?: number;
|
|
6
|
+
noiseOctaves?: number;
|
|
7
|
+
size?: number;
|
|
8
|
+
minHeight?: Property.MinHeight;
|
|
9
|
+
angle?: number;
|
|
10
|
+
gradientColor?: Property.Color;
|
|
11
|
+
backgroundColor?: Property.Color;
|
|
12
|
+
}
|
|
13
|
+
export declare const GrainyGradientBackground: ({ children, noiseFrequency, noiseOctaves, minHeight, size, angle, gradientColor, backgroundColor, }: GrainyGradientProps) => JSX.Element;
|
package/dist/esm/components/grainy-gradient-background/grainy-gradient-background.component.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export const GrainyGradientBackground = ({ children, noiseFrequency = 0.65, noiseOctaves = 3, minHeight, size = 740, angle = 20, gradientColor = 'rebeccapurple', backgroundColor = 'moccasin', }) => {
|
|
3
|
+
const gradient = `linear-gradient(${angle}deg, ${gradientColor}, transparent)`;
|
|
4
|
+
const image = `url("data:image/svg+xml,%3Csvg viewBox='0 0 ${size} ${size}' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='${noiseFrequency}' numOctaves='${noiseOctaves}' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E")`;
|
|
5
|
+
const container = {};
|
|
6
|
+
const content = {
|
|
7
|
+
position: 'absolute',
|
|
8
|
+
width: '100%',
|
|
9
|
+
height: '100%',
|
|
10
|
+
};
|
|
11
|
+
const noise = {
|
|
12
|
+
filter: 'contrast(290%) brightness(1000%)',
|
|
13
|
+
background: gradient + ', ' + image,
|
|
14
|
+
minHeight,
|
|
15
|
+
};
|
|
16
|
+
const isolate = {
|
|
17
|
+
isolation: 'isolate',
|
|
18
|
+
position: 'absolute',
|
|
19
|
+
width: '100%',
|
|
20
|
+
height: '100%',
|
|
21
|
+
};
|
|
22
|
+
const overlay = {
|
|
23
|
+
position: 'absolute',
|
|
24
|
+
top: 0,
|
|
25
|
+
width: '100%',
|
|
26
|
+
height: '100%',
|
|
27
|
+
background: backgroundColor,
|
|
28
|
+
mixBlendMode: 'multiply',
|
|
29
|
+
};
|
|
30
|
+
return (React.createElement("div", { style: container },
|
|
31
|
+
React.createElement("div", { style: isolate },
|
|
32
|
+
React.createElement("div", { style: noise }),
|
|
33
|
+
React.createElement("div", { style: overlay })),
|
|
34
|
+
React.createElement("div", { style: content }, children)));
|
|
35
|
+
};
|
|
@@ -13,7 +13,7 @@ export const IconTextRow = ({ iconName, color, align = 'left', text, textRole =
|
|
|
13
13
|
}
|
|
14
14
|
function RowText() {
|
|
15
15
|
return (React.createElement("div", { style: Object.assign(Object.assign({}, expand), { paddingLeft: textMargin, paddingRight: textMargin }) },
|
|
16
|
-
React.createElement(Text, { align: align,
|
|
16
|
+
React.createElement(Text, { align: align, colorToken: color, role: textRole }, text || children)));
|
|
17
17
|
}
|
|
18
18
|
function RowCenter() {
|
|
19
19
|
return align === 'center' ? React.createElement("div", { style: Object.assign({}, expand) }) : null;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { CSSProperties, ReactNode } from 'react';
|
|
1
|
+
import React, { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import { ContainerColorToken } from '@uni-design-system/uni-core';
|
|
2
3
|
export interface ContainerProps {
|
|
3
4
|
children: ReactNode;
|
|
4
5
|
style: CSSProperties;
|
|
6
|
+
colorToken?: ContainerColorToken;
|
|
5
7
|
}
|
|
6
|
-
export
|
|
8
|
+
export declare const ContainerContext: React.Context<{
|
|
9
|
+
colorToken?: ContainerColorToken | undefined;
|
|
10
|
+
}>;
|
|
11
|
+
export default function Container({ children, style, colorToken, ...rest }: ContainerProps): JSX.Element;
|
|
@@ -9,8 +9,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import React from 'react';
|
|
12
|
+
import React, { createContext } from 'react';
|
|
13
|
+
export const ContainerContext = createContext({});
|
|
13
14
|
export default function Container(_a) {
|
|
14
|
-
var { children, style } = _a, rest = __rest(_a, ["children", "style"]);
|
|
15
|
-
return (React.createElement(
|
|
15
|
+
var { children, style, colorToken } = _a, rest = __rest(_a, ["children", "style", "colorToken"]);
|
|
16
|
+
return (React.createElement(ContainerContext.Provider, { value: { colorToken } },
|
|
17
|
+
React.createElement("div", Object.assign({ style: style }, rest), children)));
|
|
16
18
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
2
|
import { FontWeightMap, } from '@uni-design-system/uni-core';
|
|
3
3
|
import { useTheme } from '../theme';
|
|
4
|
+
import { ContainerContext } from '../container';
|
|
4
5
|
export function Text(props) {
|
|
5
|
-
const { text, children, align, role = 'body-1-long',
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return {
|
|
13
|
-
color: theme.colors[color || 'on-background'],
|
|
6
|
+
const { text, children, align, role = 'body-1-long', colorToken: overridingColorToken } = props;
|
|
7
|
+
const { colors, typography } = useTheme();
|
|
8
|
+
const { colorToken: containerColorToken } = useContext(ContainerContext);
|
|
9
|
+
const colorToken = containerColorToken ? `on-${containerColorToken}` : undefined;
|
|
10
|
+
const { fontSize, letterSpacing, lineHeight, fontWeight, fontFamily, fontStyle, textTransform } = typography[role];
|
|
11
|
+
const style = {
|
|
12
|
+
color: colors[overridingColorToken || colorToken || 'on-surface'],
|
|
14
13
|
fontSize: fontSize + 'px',
|
|
15
14
|
letterSpacing,
|
|
16
|
-
textAlign,
|
|
15
|
+
textAlign: align,
|
|
17
16
|
textTransform,
|
|
18
17
|
lineHeight: lineHeight + 'px',
|
|
19
18
|
fontFamily,
|
|
20
19
|
fontStyle,
|
|
21
20
|
fontWeight: FontWeightMap[fontWeight],
|
|
22
21
|
};
|
|
22
|
+
return React.createElement("div", { style: style }, text || children);
|
|
23
23
|
}
|