@ttoss/ui 1.30.1 → 1.30.2
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/esm/index.js +581 -172
- package/dist/index.d.ts +8 -4
- package/dist/index.js +559 -167
- package/package.json +10 -10
- package/src/components/Button.tsx +54 -9
- package/src/index.ts +2 -5
- package/src/theme/ThemeProvider.tsx +13 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/ui",
|
|
3
|
-
"version": "1.30.
|
|
3
|
+
"version": "1.30.2",
|
|
4
4
|
"description": "Primitive layout, typographic, and other components for styling applications.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -22,20 +22,20 @@
|
|
|
22
22
|
"typings": "dist/index.d.ts",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@emotion/react": "^11.10.5",
|
|
25
|
-
"@theme-ui/match-media": "^0.15.
|
|
26
|
-
"theme-ui": "^0.15.
|
|
25
|
+
"@theme-ui/match-media": "^0.15.5",
|
|
26
|
+
"theme-ui": "^0.15.5"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"react": ">=16.8.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@iconify-icon/react": "^1.0.
|
|
33
|
-
"@ttoss/config": "^1.28.
|
|
34
|
-
"@ttoss/test-utils": "^1.20.
|
|
35
|
-
"@ttoss/theme": "^1.2.
|
|
32
|
+
"@iconify-icon/react": "^1.0.5",
|
|
33
|
+
"@ttoss/config": "^1.28.1",
|
|
34
|
+
"@ttoss/test-utils": "^1.20.3",
|
|
35
|
+
"@ttoss/theme": "^1.2.4",
|
|
36
36
|
"@types/jest": "^29.4.0",
|
|
37
|
-
"jest": "^29.4.
|
|
38
|
-
"tsup": "^6.
|
|
37
|
+
"jest": "^29.4.2",
|
|
38
|
+
"tsup": "^6.6.3"
|
|
39
39
|
},
|
|
40
40
|
"keywords": [
|
|
41
41
|
"React",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "d4df96176c1d3fce4ebf7842de5847a618a33d9e"
|
|
49
49
|
}
|
|
@@ -1,12 +1,57 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
type ButtonProps as ButtonPropsUi,
|
|
4
|
+
Button as ButtonUi,
|
|
5
|
+
} from 'theme-ui';
|
|
6
|
+
import { Icon } from './Icon';
|
|
2
7
|
|
|
3
|
-
export type
|
|
8
|
+
export type ButtonProps = ButtonPropsUi & {
|
|
9
|
+
leftIcon?: React.ReactNode | string;
|
|
10
|
+
rightIcon?: React.ReactNode | string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const RenderIcon = ({ icon }: { icon: React.ReactNode | string }) => {
|
|
14
|
+
if (!icon) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
4
17
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
if (typeof icon === 'string') {
|
|
19
|
+
return (
|
|
20
|
+
<>
|
|
21
|
+
<Icon icon={icon} />
|
|
22
|
+
</>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return <>{icon}</>;
|
|
12
27
|
};
|
|
28
|
+
|
|
29
|
+
const MemoizedRenderIcon = React.memo(RenderIcon);
|
|
30
|
+
|
|
31
|
+
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
32
|
+
(props, ref) => {
|
|
33
|
+
const { children, leftIcon, rightIcon, ...restProps } = props;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<ButtonUi
|
|
37
|
+
ref={ref}
|
|
38
|
+
{...restProps}
|
|
39
|
+
sx={{
|
|
40
|
+
cursor: 'pointer',
|
|
41
|
+
paddingX: 'lg',
|
|
42
|
+
paddingY: 'md',
|
|
43
|
+
display: 'inline-flex',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
gap: 'lg',
|
|
46
|
+
...restProps.sx,
|
|
47
|
+
}}
|
|
48
|
+
>
|
|
49
|
+
<MemoizedRenderIcon icon={leftIcon} />
|
|
50
|
+
{children}
|
|
51
|
+
<MemoizedRenderIcon icon={rightIcon} />
|
|
52
|
+
</ButtonUi>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
Button.displayName = 'Button';
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export { BaseStyles, type Theme } from 'theme-ui';
|
|
2
2
|
export { useResponsiveValue, useBreakpointIndex } from '@theme-ui/match-media';
|
|
3
3
|
|
|
4
|
-
export {
|
|
5
|
-
default as ThemeProvider,
|
|
6
|
-
type ThemeProviderProps,
|
|
7
|
-
} from './theme/ThemeProvider';
|
|
4
|
+
export { ThemeProvider, type ThemeProviderProps } from './theme/ThemeProvider';
|
|
8
5
|
|
|
9
6
|
export { useTheme } from './theme/useTheme';
|
|
10
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { BruttalFonts, BruttalTheme } from '@ttoss/theme';
|
|
3
3
|
import { Global, css } from '@emotion/react';
|
|
4
|
-
import { Theme, ThemeProvider as ThemeUiProvider
|
|
4
|
+
import { Theme, ThemeProvider as ThemeUiProvider } from 'theme-ui';
|
|
5
5
|
|
|
6
6
|
export type ThemeProviderProps = {
|
|
7
7
|
children?: React.ReactNode;
|
|
@@ -12,36 +12,25 @@ export type ThemeProviderProps = {
|
|
|
12
12
|
fonts?: string[];
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
const ThemeProvider = ({
|
|
15
|
+
export const ThemeProvider = ({
|
|
16
16
|
children,
|
|
17
|
-
theme =
|
|
17
|
+
theme = BruttalTheme,
|
|
18
18
|
fonts = BruttalFonts,
|
|
19
19
|
}: ThemeProviderProps) => {
|
|
20
|
-
const mergedTheme = React.useMemo(() => {
|
|
21
|
-
if (typeof theme === 'function') {
|
|
22
|
-
return theme;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return merge(BruttalTheme, theme);
|
|
26
|
-
}, [theme]);
|
|
27
|
-
|
|
28
20
|
return (
|
|
29
21
|
<>
|
|
30
|
-
<ThemeUiProvider theme={
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
})}
|
|
22
|
+
<ThemeUiProvider theme={theme}>
|
|
23
|
+
<Global
|
|
24
|
+
styles={css`
|
|
25
|
+
${fonts
|
|
26
|
+
.map((url) => {
|
|
27
|
+
return `@import url('${url}');`;
|
|
28
|
+
})
|
|
29
|
+
.join('\n')}
|
|
30
|
+
`}
|
|
31
|
+
/>
|
|
41
32
|
{children}
|
|
42
33
|
</ThemeUiProvider>
|
|
43
34
|
</>
|
|
44
35
|
);
|
|
45
36
|
};
|
|
46
|
-
|
|
47
|
-
export default ThemeProvider;
|