@manamerge/mana-atomic-ui 0.0.20 → 0.0.21
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/README.md +7 -1
- package/dist/index.d.ts +11 -4
- package/dist/index.js +96 -3
- package/dist/index.js.map +1 -1
- package/dist/types/components/Atoms/Button/Button.css.d.ts +7 -0
- package/dist/types/components/Atoms/Button/Button.d.ts +74 -0
- package/dist/types/components/Atoms/Button/Button.stories.d.ts +6 -0
- package/dist/types/components/index.d.ts +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
-
interface
|
|
4
|
-
|
|
3
|
+
interface ButtonTypes {
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
className: string;
|
|
6
|
+
image?: string | null;
|
|
7
|
+
background?: string;
|
|
8
|
+
alt?: string;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
onClick?: (e: any) => void;
|
|
11
|
+
type?: 'button' | 'submit' | 'reset' | undefined;
|
|
5
12
|
}
|
|
6
|
-
declare const Button:
|
|
13
|
+
declare const Button: React.FC<ButtonTypes>;
|
|
7
14
|
|
|
8
15
|
declare const Wrapper1: React.FC;
|
|
9
16
|
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,102 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
3
4
|
|
|
4
|
-
const
|
|
5
|
-
|
|
5
|
+
const ButtonStyle = styled.button `
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
gap: 10px;
|
|
9
|
+
padding: 10px;
|
|
10
|
+
outline-color: transparent;
|
|
11
|
+
|
|
12
|
+
/*csslint important: false*/
|
|
13
|
+
${({ background }) => background &&
|
|
14
|
+
css `
|
|
15
|
+
background: center/cover url(${background});
|
|
16
|
+
background-size: contain;
|
|
17
|
+
background-repeat: no-repeat;
|
|
18
|
+
`}
|
|
19
|
+
/*csslint important: true*/
|
|
20
|
+
|
|
21
|
+
:focus-visible {
|
|
22
|
+
outline: 2px solid #00a1f1;
|
|
23
|
+
outline-offset: 2px;
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
const ImgStyle = styled.svg `
|
|
27
|
+
width: 1em;
|
|
28
|
+
height: 1em;
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
const Button = ({ className, disabled, image, background, alt, children, onClick, type, }) => {
|
|
32
|
+
if (!children && !alt) {
|
|
33
|
+
console.error(`Provide children or alt property to Button ${className}`);
|
|
34
|
+
}
|
|
35
|
+
return (React.createElement(ButtonStyle, { disabled: disabled || false, className: classNames('Button', className), type: type || 'submit', "aria-label": alt || '', onClick: (e) => {
|
|
36
|
+
if (onClick) {
|
|
37
|
+
onClick(e);
|
|
38
|
+
}
|
|
39
|
+
}, background: background || '' },
|
|
40
|
+
image && (React.createElement(ImgStyle, { viewBox: '0 0 100 100' },
|
|
41
|
+
React.createElement("defs", null,
|
|
42
|
+
React.createElement("mask", { id: `${image}-mask` },
|
|
43
|
+
React.createElement("image", { xlinkHref: image, width: '100', height: '100' }))),
|
|
44
|
+
React.createElement("rect", { width: '100', height: '100', style: { fill: 'var(--alt-color, currentColor)' }, mask: `url(#${image}-mask)` }))),
|
|
45
|
+
children));
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
export const ButtonSettings: ISettings = {
|
|
49
|
+
states: [State.default, State.active, State.hover, State.disabled],
|
|
50
|
+
include: [
|
|
51
|
+
CmsConfig.frame,
|
|
52
|
+
CmsConfig.border,
|
|
53
|
+
CmsConfig.text,
|
|
54
|
+
CmsConfig.color,
|
|
55
|
+
CmsConfig.altColor,
|
|
56
|
+
CmsConfig.fill,
|
|
57
|
+
// CmsConfig.effects,
|
|
58
|
+
CmsConfig.padding,
|
|
59
|
+
CmsConfig.flexbox,
|
|
60
|
+
CmsConfig.cursor,
|
|
61
|
+
CmsConfig.hmargin,
|
|
62
|
+
// CmsConfig.display,
|
|
63
|
+
],
|
|
64
|
+
variants: [
|
|
65
|
+
{
|
|
66
|
+
className: '&primary',
|
|
67
|
+
description: 'Button Primary',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
className: '&secondary',
|
|
71
|
+
description: 'Button Secondary',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
className: '&tertiary',
|
|
75
|
+
description: 'Button Ternary',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
className: '&quaternary',
|
|
79
|
+
description: 'Button Quinary',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
className: '&quinary',
|
|
83
|
+
description: 'Button Quinary',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
className: '&senary',
|
|
87
|
+
description: 'Button Senary',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
className: '&septenary',
|
|
91
|
+
description: 'Button Septenary',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
className: '&octonary',
|
|
95
|
+
description: 'Button Octonary',
|
|
96
|
+
},
|
|
97
|
+
],
|
|
6
98
|
};
|
|
99
|
+
*/
|
|
7
100
|
|
|
8
101
|
// src/components/Wrapper.tsx
|
|
9
102
|
const Wrapper = styled.div `
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/components/Button/Button.tsx","../src/components/Wrapper/Wrapper.css.tsx","../src/components/Wrapper/Wrapper.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/components/Atoms/Button/Button.css.ts","../src/components/Atoms/Button/Button.tsx","../src/components/Wrapper/Wrapper.css.tsx","../src/components/Wrapper/Wrapper.tsx"],"sourcesContent":["import styled, { css } from 'styled-components';\n\ninterface ButtonProps {\n background: string;\n}\n\nexport const ButtonStyle = styled.button<ButtonProps>`\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px;\n outline-color: transparent;\n\n /*csslint important: false*/\n ${({ background }) =>\n background &&\n css`\n background: center/cover url(${background});\n background-size: contain;\n background-repeat: no-repeat;\n `}\n /*csslint important: true*/\n \n :focus-visible {\n outline: 2px solid #00a1f1;\n outline-offset: 2px;\n }\n`;\n\nexport const ImgStyle = styled.svg`\n width: 1em;\n height: 1em;\n`;\n","import React, { ReactNode } from 'react';\nimport classNames from 'classnames';\n// import { CmsConfig } from '../../../definitions/CmsConfig';\n// import { ISettings } from '../../../definitions/ISettings';\n// import { State } from '../../../definitions/States';\nimport { ButtonStyle, ImgStyle } from './Button.css';\n\n/*\nImplementation examples:\n========================\n\nimport {Button} from '@dexper.events/product-atomic-ui';\n\nconst svgSrc = 'https://dexper-product-development.web.app/static/media/user.2c0a844d.svg';\nconst profilePhoto = 'https://firebasestorage.googleapis.com/v0/b/dexper-product-development.appspot.com/o/assets%2Fimages%2Fprofile-photo.jpg?alt=media&token=bcdeb824-f3a4-4532-821b-34c4b06a56af';\n\n<Button onClick={() => {console.log('click')}}>Click me!</Button>\n\n// Button with text and icon\n\n<Button image={svgSrc}>Click me!</Button>\n\n// When a button only has an icon, provide an alt parameter describing the icon\n// to comply with WCAG\n\n<Button image={svgSrc} alt=\"Icon of person\"/>\n\n// Image as a button. Provide alt parameter.\n\n<Button background={profilePhoto} alt=\"Evelyn Hill\"/>\n\n*/\n\nexport interface ButtonTypes {\n disabled?: boolean;\n className: string;\n image?: string | null;\n background?: string;\n alt?: string;\n children?: ReactNode;\n onClick?: (e: any) => void;\n type?: 'button' | 'submit' | 'reset' | undefined;\n}\n\nexport const ButtonStory = {\n className: 'primary',\n disabled: false,\n image:\n 'https://dexper-product-development.web.app/static/media/user.2c0a844d.svg',\n background:\n 'https://firebasestorage.googleapis.com/v0/b/dexper-product-development.appspot.com/o/assets%2Fimages%2Fprofile-photo.jpg?alt=media&token=bcdeb824-f3a4-4532-821b-34c4b06a56af',\n children: 'Click me',\n alt: 'Icon of person',\n onClick: () => {\n console.log('story assigned event');\n },\n};\n\nexport const Button: React.FC<ButtonTypes> = ({\n className,\n disabled,\n image,\n background,\n alt,\n children,\n onClick,\n type,\n}) => {\n if (!children && !alt) {\n console.error(`Provide children or alt property to Button ${className}`);\n }\n\n return (\n <ButtonStyle\n disabled={disabled || false}\n className={classNames('Button', className)}\n type={type || 'submit'}\n aria-label={alt || ''}\n onClick={(e) => {\n if (onClick) {\n onClick(e);\n }\n }}\n background={background || ''}\n >\n {image && (\n <ImgStyle viewBox='0 0 100 100'>\n <defs>\n <mask id={`${image}-mask`}>\n <image xlinkHref={image} width='100' height='100' />\n </mask>\n </defs>\n <rect\n width='100'\n height='100'\n style={{ fill: 'var(--alt-color, currentColor)' }}\n mask={`url(#${image}-mask)`}\n />\n </ImgStyle>\n )}\n {children}\n </ButtonStyle>\n );\n};\n/**\nexport const ButtonSettings: ISettings = {\n states: [State.default, State.active, State.hover, State.disabled],\n include: [\n CmsConfig.frame,\n CmsConfig.border,\n CmsConfig.text,\n CmsConfig.color,\n CmsConfig.altColor,\n CmsConfig.fill,\n // CmsConfig.effects,\n CmsConfig.padding,\n CmsConfig.flexbox,\n CmsConfig.cursor,\n CmsConfig.hmargin,\n // CmsConfig.display,\n ],\n variants: [\n {\n className: '&primary',\n description: 'Button Primary',\n },\n {\n className: '&secondary',\n description: 'Button Secondary',\n },\n {\n className: '&tertiary',\n description: 'Button Ternary',\n },\n {\n className: '&quaternary',\n description: 'Button Quinary',\n },\n {\n className: '&quinary',\n description: 'Button Quinary',\n },\n {\n className: '&senary',\n description: 'Button Senary',\n },\n {\n className: '&septenary',\n description: 'Button Septenary',\n },\n {\n className: '&octonary',\n description: 'Button Octonary',\n },\n ],\n};\n */\n","// src/components/Wrapper.tsx\n\nimport styled from \"styled-components\";\n\ninterface WrapperProps {\n padding?: string;\n margin?: string;\n backgroundColor?: string;\n}\n\nconst Wrapper = styled.div<WrapperProps>`\n padding: ${(props) => props.padding || \"1rem\"};\n margin: ${(props) => props.margin || \"0 auto\"};\n background-color: ${(props) => props.backgroundColor || \"red\"};\n`;\n\nexport default Wrapper;\n","import React from \"react\";\nimport Wrapper from \"./Wrapper.css\";\n\nexport interface WrapperProps {\n children?: string;\n padding?: string;\n margin?: string;\n backgroundColor?: string;\n}\n// const Button = ({ label }: ButtonProps) => {\n\nconst Wrapper1: React.FC = (args: WrapperProps) => {\n return (\n <Wrapper\n padding={args.padding}\n margin=\"1rem auto\"\n backgroundColor={args.backgroundColor}\n >\n <h1>Hello, World!</h1>\n <p>This is a simple wrapper component.</p>\n </Wrapper>\n );\n};\n\nexport default Wrapper1;\n"],"names":[],"mappings":";;;;AAMO,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAa,CAAA;;;;;;;;AAQjD,EAAA,EAAA,CAAC,EAAE,UAAU,EAAE,KACf,UAAU;AACV,IAAA,GAAG,CAAA,CAAA;qCAC8B,UAAU,CAAA;;;AAG1C,IAAA,CAAA,CAAA;;;;;;;CAOJ,CAAC;AAEK,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAA,CAAA;;;CAGjC;;MC0BY,MAAM,GAA0B,CAAC,EAC5C,SAAS,EACT,QAAQ,EACR,KAAK,EACL,UAAU,EACV,GAAG,EACH,QAAQ,EACR,OAAO,EACP,IAAI,GACL,KAAI;AACH,IAAA,IAAI,CAAC,QAAQ,IAAI,CAAC,GAAG,EAAE;AACrB,QAAA,OAAO,CAAC,KAAK,CAAC,8CAA8C,SAAS,CAAA,CAAE,CAAC,CAAC;AAC1E,KAAA;AAED,IAAA,QACE,KAAA,CAAA,aAAA,CAAC,WAAW,EAAA,EACV,QAAQ,EAAE,QAAQ,IAAI,KAAK,EAC3B,SAAS,EAAE,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC,EAC1C,IAAI,EAAE,IAAI,IAAI,QAAQ,EACV,YAAA,EAAA,G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AAA,aAAA,CAAA,OAAO,IACN,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,MAAM,EAAC,WAAW,EAClB,eAAe,EAAE,IAAI,CAAC,eAAe,EAAA;QAErC,KAAsB,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA,EAAA,eAAA,CAAA;QACtB,KAA0C,CAAA,aAAA,CAAA,GAAA,EAAA,IAAA,EAAA,qCAAA,CAAA,CAClC,EACV;AACJ;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface ButtonProps {
|
|
3
|
+
background: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const ButtonStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, ButtonProps>> & string;
|
|
6
|
+
export declare const ImgStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").SVGProps<SVGSVGElement>, never>> & string;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
export interface ButtonTypes {
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
className: string;
|
|
5
|
+
image?: string | null;
|
|
6
|
+
background?: string;
|
|
7
|
+
alt?: string;
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
onClick?: (e: any) => void;
|
|
10
|
+
type?: 'button' | 'submit' | 'reset' | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare const ButtonStory: {
|
|
13
|
+
className: string;
|
|
14
|
+
disabled: boolean;
|
|
15
|
+
image: string;
|
|
16
|
+
background: string;
|
|
17
|
+
children: string;
|
|
18
|
+
alt: string;
|
|
19
|
+
onClick: () => void;
|
|
20
|
+
};
|
|
21
|
+
export declare const Button: React.FC<ButtonTypes>;
|
|
22
|
+
/**
|
|
23
|
+
export const ButtonSettings: ISettings = {
|
|
24
|
+
states: [State.default, State.active, State.hover, State.disabled],
|
|
25
|
+
include: [
|
|
26
|
+
CmsConfig.frame,
|
|
27
|
+
CmsConfig.border,
|
|
28
|
+
CmsConfig.text,
|
|
29
|
+
CmsConfig.color,
|
|
30
|
+
CmsConfig.altColor,
|
|
31
|
+
CmsConfig.fill,
|
|
32
|
+
// CmsConfig.effects,
|
|
33
|
+
CmsConfig.padding,
|
|
34
|
+
CmsConfig.flexbox,
|
|
35
|
+
CmsConfig.cursor,
|
|
36
|
+
CmsConfig.hmargin,
|
|
37
|
+
// CmsConfig.display,
|
|
38
|
+
],
|
|
39
|
+
variants: [
|
|
40
|
+
{
|
|
41
|
+
className: '&primary',
|
|
42
|
+
description: 'Button Primary',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
className: '&secondary',
|
|
46
|
+
description: 'Button Secondary',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
className: '&tertiary',
|
|
50
|
+
description: 'Button Ternary',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
className: '&quaternary',
|
|
54
|
+
description: 'Button Quinary',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
className: '&quinary',
|
|
58
|
+
description: 'Button Quinary',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
className: '&senary',
|
|
62
|
+
description: 'Button Senary',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
className: '&septenary',
|
|
66
|
+
description: 'Button Septenary',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
className: '&octonary',
|
|
70
|
+
description: 'Button Octonary',
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
};
|
|
74
|
+
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Button } from "./Atoms/Button/Button";
|
|
2
2
|
export { default as Wrapper } from "./Wrapper";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manamerge/mana-atomic-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "Mana Merge design system",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "rollup -c",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
],
|
|
48
48
|
"types": "dist/index.d.ts",
|
|
49
49
|
"dependencies": {
|
|
50
|
+
"classnames": "^2.5.1",
|
|
50
51
|
"styled-components": "^6.1.11"
|
|
51
52
|
}
|
|
52
53
|
}
|