@vaneui/ui 0.0.7 → 0.0.8

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/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@vaneui/ui",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.esm.js",
8
8
  "types": "dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
9
12
  "exports": {
10
13
  ".": {
11
14
  "import": "./dist/index.esm.js",
@@ -18,10 +21,10 @@
18
21
  "types": "./dist/components/complex/index.d.ts"
19
22
  },
20
23
  "./css/ui": {
21
- "css": "./dist/ui.css"
24
+ "import": "./dist/ui.css"
22
25
  },
23
26
  "./css/complex": {
24
- "css": "./dist/complex.css"
27
+ "import": "./dist/complex.css"
25
28
  }
26
29
  },
27
30
  "scripts": {
@@ -53,4 +56,4 @@
53
56
  "tslib": "^2.8.1",
54
57
  "typescript": "^5.8.2"
55
58
  }
56
- }
59
+ }
@@ -1,65 +0,0 @@
1
- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
-
4
- name: Npm publish on push
5
-
6
- on: [push]
7
-
8
- jobs:
9
- build:
10
- runs-on: ubuntu-latest
11
- steps:
12
- - name: Checkout Code
13
- uses: actions/checkout@v4
14
-
15
- - name: Setup Node.js
16
- uses: actions/setup-node@v3
17
- with:
18
- node-version: '20'
19
- registry-url: 'https://registry.npmjs.org'
20
- cache: 'npm'
21
-
22
- - name: Install Dependencies
23
- run: npm ci
24
-
25
- - name: Build Package
26
- run: npm run build
27
-
28
- publish-npm:
29
- needs: build
30
- runs-on: ubuntu-latest
31
- steps:
32
- - name: Checkout Code
33
- uses: actions/checkout@v4
34
-
35
- - name: Setup Node.js
36
- uses: actions/setup-node@v3
37
- with:
38
- node-version: '20'
39
- registry-url: 'https://registry.npmjs.org'
40
-
41
- - name: Install Dependencies
42
- run: npm ci
43
-
44
- - name: Check if Version Already Published
45
- id: check_version
46
- run: |
47
- # Get version from package.json
48
- VERSION=$(node -p "require('./package.json').version")
49
- echo "Local package version: $VERSION"
50
- # Get published version for the package (@vaneui/ui) or "none" if not published.
51
- PUBLISHED_VERSION=$(npm view @vaneui/ui version || echo "none")
52
- echo "Published package version: $PUBLISHED_VERSION"
53
- if [ "$VERSION" = "$PUBLISHED_VERSION" ]; then
54
- echo "Version already published. Skipping publish step."
55
- echo "shouldPublish=false" >> $GITHUB_OUTPUT
56
- else
57
- echo "Version is new. Proceeding with publish."
58
- echo "shouldPublish=true" >> $GITHUB_OUTPUT
59
- fi
60
-
61
- - name: Publish Package to npm
62
- if: steps.check_version.outputs.shouldPublish == 'true'
63
- run: npm publish --access public
64
- env:
65
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -1,5 +0,0 @@
1
- {
2
- "cSpell.words": [
3
- "vaneui"
4
- ]
5
- }
package/rollup.config.mjs DELETED
@@ -1,45 +0,0 @@
1
- import peerDepsExternal from "rollup-plugin-peer-deps-external";
2
- import resolve from "@rollup/plugin-node-resolve";
3
- import commonjs from "@rollup/plugin-commonjs";
4
- import typescript from "rollup-plugin-typescript2";
5
- import pkg from "./package.json";
6
-
7
- export default [
8
- {
9
- input: "src/index.ts",
10
- output: [
11
- {
12
- file: pkg.main,
13
- format: "cjs",
14
- sourcemap: true,
15
- },
16
- {
17
- file: pkg.module,
18
- format: "esm",
19
- sourcemap: true,
20
- },
21
- ],
22
- plugins: [
23
- peerDepsExternal(),
24
- resolve(),
25
- commonjs(),
26
- typescript({ tsconfig: "./tsconfig.json" }),
27
- ],
28
- },
29
- {
30
- input: "src/components/complex/index.ts",
31
- output: [
32
- {
33
- file: "dist/components/complex/index.js",
34
- format: "esm",
35
- sourcemap: true,
36
- },
37
- ],
38
- plugins: [
39
- peerDepsExternal(),
40
- resolve(),
41
- commonjs(),
42
- typescript({ tsconfig: "./tsconfig.complex.json" }),
43
- ],
44
- },
45
- ];
@@ -1 +0,0 @@
1
- @import "tailwindcss";
@@ -1 +0,0 @@
1
- export { SocialShare } from "./sharer";
@@ -1,216 +0,0 @@
1
- import React from 'react';
2
-
3
- type Platform = 'fb' | 'li' | 'x' | 'th' | 'em' | 'wa' | 'tg' | 're';
4
-
5
- interface SocialShareCommonProps {
6
- url?: string;
7
- text?: string;
8
- width?: number;
9
- height?: number;
10
- isLink?: boolean;
11
- isBlank?: boolean;
12
- platforms?: Platform[];
13
- containerComponent?: React.ElementType;
14
- buttonComponent?: React.ElementType;
15
- buttonComponents?: Partial<Record<Platform, React.ElementType>>;
16
- }
17
-
18
- interface FacebookShareProps {
19
- hashtag?: string;
20
- }
21
-
22
- interface TwitterShareProps {
23
- hashtags?: string;
24
- via?: string;
25
- related?: string;
26
- inReplyTo?: string;
27
- }
28
-
29
- interface EmailShareProps {
30
- title?: string;
31
- to?: string;
32
- }
33
-
34
- interface WhatsAppShareProps {
35
- to?: string;
36
- web?: boolean;
37
- }
38
-
39
- interface SocialShareProps extends SocialShareCommonProps {
40
- facebookProps?: FacebookShareProps;
41
- twitterProps?: TwitterShareProps;
42
- emailProps?: EmailShareProps;
43
- whatsappProps?: WhatsAppShareProps;
44
- }
45
-
46
- interface ShareConfig {
47
- shareUrl: string;
48
- getParams: () => { [key: string]: string | number | boolean | undefined };
49
- }
50
-
51
- const buildQueryString = (
52
- params: { [key: string]: string | number | boolean | undefined }
53
- ): string => {
54
- const validKeys = Object.keys(params).filter(
55
- key => params[key] !== undefined && params[key] !== ''
56
- );
57
- return validKeys.length > 0
58
- ? '?' +
59
- validKeys
60
- .map(key => `${key}=${encodeURIComponent(String(params[key]))}`)
61
- .join('&')
62
- : '';
63
- };
64
-
65
- export const SocialShare: React.FC<SocialShareProps> = ({
66
- url = window.location.href,
67
- text = '',
68
- width = 600,
69
- height = 480,
70
- isLink = false,
71
- isBlank = true,
72
- platforms,
73
- containerComponent,
74
- buttonComponent,
75
- buttonComponents,
76
- facebookProps = {},
77
- twitterProps = {},
78
- emailProps = {},
79
- whatsappProps = {},
80
- }) => {
81
- const shareConfigs: { [key in Platform]: ShareConfig } = {
82
- fb: {
83
- shareUrl: 'https://www.facebook.com/sharer/sharer.php',
84
- getParams: () => ({
85
- u: url,
86
- hashtag: facebookProps.hashtag
87
- ? facebookProps.hashtag.startsWith('#')
88
- ? facebookProps.hashtag
89
- : `#${facebookProps.hashtag}`
90
- : '',
91
- quote: text,
92
- }),
93
- },
94
- li: {
95
- shareUrl: 'https://www.linkedin.com/shareArticle',
96
- getParams: () => ({
97
- url,
98
- }),
99
- },
100
- x: {
101
- shareUrl: 'https://x.com/intent/tweet',
102
- getParams: () => ({
103
- text,
104
- url,
105
- hashtags: twitterProps.hashtags,
106
- via: twitterProps.via,
107
- related: twitterProps.related,
108
- in_reply_to: twitterProps.inReplyTo,
109
- }),
110
- },
111
- th: {
112
- shareUrl: 'https://threads.net/intent/post',
113
- getParams: () => ({
114
- text: `${text} ${url}`,
115
- }),
116
- },
117
- em: {
118
- shareUrl: 'mailto:' + (emailProps.to || ''),
119
- getParams: () => ({
120
- subject: emailProps.title,
121
- body: `${text}\n${url}`,
122
- }),
123
- },
124
- wa: {
125
- shareUrl: whatsappProps.web
126
- ? 'https://web.whatsapp.com/send'
127
- : 'https://wa.me/',
128
- getParams: () => ({
129
- phone: whatsappProps.to,
130
- text: `${text} ${url}`,
131
- }),
132
- },
133
- tg: {
134
- shareUrl: 'https://t.me/share',
135
- getParams: () => ({
136
- text,
137
- url,
138
- }),
139
- },
140
- re: {
141
- shareUrl: 'https://www.reddit.com/submit',
142
- getParams: () => ({
143
- url,
144
- title: text,
145
- }),
146
- },
147
- };
148
-
149
- const platformLabels: { [key in Platform]: string } = {
150
- fb: 'Facebook',
151
- li: 'LinkedIn',
152
- x: 'X',
153
- th: 'Threads',
154
- em: 'Email',
155
- wa: 'WhatsApp',
156
- tg: 'Telegram',
157
- re: 'Reddit',
158
- };
159
-
160
- const buildShareUrl = (config: ShareConfig): string => {
161
- const params = config.getParams();
162
- const queryString = buildQueryString(params);
163
- return config.shareUrl + queryString;
164
- };
165
-
166
- const openShareWindow = (shareUrl: string): void => {
167
- if (isLink) {
168
- if (isBlank) {
169
- window.open(shareUrl, '_blank');
170
- } else {
171
- window.location.href = shareUrl;
172
- }
173
- } else {
174
- const left = window.innerWidth / 2 - width / 2 + window.screenX;
175
- const top = window.innerHeight / 2 - height / 2 + window.screenY;
176
- const popParams = `scrollbars=no, width=${width}, height=${height}, top=${top}, left=${left}`;
177
- const newWindow = window.open(shareUrl, '', popParams);
178
- if (newWindow) {
179
- newWindow.focus();
180
- }
181
- }
182
- };
183
-
184
- const handleShare = (key: Platform): void => {
185
- const config = shareConfigs[key];
186
- if (!config) return;
187
- const shareUrl = buildShareUrl(config);
188
- openShareWindow(shareUrl);
189
- };
190
-
191
- // Use the provided container component or default to 'div'
192
- const Container = containerComponent || 'div';
193
- // Default button component to use if no platform-specific component is provided
194
- const DefaultButton = buttonComponent || 'button';
195
- const platformsToShow: Platform[] =
196
- platforms || (Object.keys(shareConfigs) as Platform[]);
197
-
198
- return (
199
- <Container>
200
- {platformsToShow.map(key => {
201
- // Use a specific button component if defined for the key
202
- const Button = (buttonComponents && buttonComponents[key]) || DefaultButton;
203
- const label = platformLabels[key] || key;
204
- return (
205
- <Button
206
- key={key}
207
- onClick={() => handleShare(key)}
208
- title={`Share on ${label}`}
209
- >
210
- {label}
211
- </Button>
212
- );
213
- })}
214
- </Container>
215
- );
216
- };
@@ -1,32 +0,0 @@
1
- import React from 'react';
2
- import { componentBuilder } from "../utils/componentBuilder";
3
- import { TypographyComponentProps } from "./props/props";
4
-
5
- export const Badge: React.FC<TypographyComponentProps> = (props) =>
6
- componentBuilder(props, "span", "rounded-full w-fit")
7
- .withSizes({
8
- xs: "px-2 py-1 text-xs",
9
- sm: "px-3 py-1 text-sm",
10
- md: "px-4 py-2 text-base",
11
- lg: "px-5 py-2 text-lg",
12
- xl: "px-6 py-3 text-xl",
13
- })
14
- .withAppearance({
15
- default: "bg-gray-200",
16
- accent: "bg-gray-200",
17
- primary: "bg-blue-200",
18
- secondary: "bg-gray-200",
19
- tertiary: "bg-gray-200",
20
- success: "bg-green-200",
21
- danger: "bg-red-200",
22
- warning: "bg-yellow-200",
23
- info: "bg-blue-200"
24
- }, {})
25
- .withTypography({
26
- fontWeight: { semibold: true },
27
- fontFamily: { mono: true },
28
- textTransform: { uppercase: true },
29
- textAppearance: { secondary: true },
30
- })
31
- .build();
32
-
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- import { componentBuilder } from "../utils/componentBuilder";
3
- import { TypographyComponentProps } from "./props/props";
4
-
5
- export const Button: React.FC<TypographyComponentProps> = (props) =>
6
- componentBuilder(props, "button", "w-fit h-fit cursor-pointer flex justify-center items-center border border-gray-200 transition-all duration-300")
7
- .withSizes({
8
- xs: "px-2 py-1 rounded-sm text-xs",
9
- sm: "px-3 py-1 rounded-md text-sm",
10
- md: "px-4 py-2 rounded-md text-base",
11
- lg: "px-6 py-3 rounded-lg text-lg",
12
- xl: "px-8 py-4 rounded-xl text-xl",
13
- })
14
- .withSizes({
15
- xs: "shadow-xs hover:shadow-sm",
16
- sm: "shadow-xs hover:shadow-sm",
17
- md: "shadow-sm hover:shadow-md",
18
- lg: "shadow-md hover:shadow-lg",
19
- xl: "shadow-lg hover:shadow-xl",
20
- })
21
- .withTypography({
22
- fontWeight: { semibold: true },
23
- })
24
- .build();
@@ -1,29 +0,0 @@
1
- import React from 'react';
2
- import { componentBuilder } from "./../utils/componentBuilder";
3
- import { TypographyComponentProps } from "./props/props";
4
-
5
- export const Chip: React.FC<TypographyComponentProps> = (props) =>
6
- componentBuilder(props, "span", "rounded-full w-fit h-fit border")
7
- .withSizes({
8
- xs: "px-1 py-1 rounded-sm text-xs",
9
- sm: "px-2 py-1 rounded-md text-sm",
10
- md: "px-2 py-1 rounded-lg text-base",
11
- lg: "px-3 py-2 rounded-xl text-lg",
12
- xl: "px-4 py-3 rounded-2xl text-xl",
13
- })
14
- .withAppearance({
15
- default: "bg-gray-100",
16
- accent: "bg-gray-200",
17
- primary: "bg-blue-200",
18
- secondary: "bg-gray-200",
19
- tertiary: "bg-gray-200",
20
- success: "bg-green-200",
21
- danger: "bg-red-200",
22
- warning: "bg-yellow-200",
23
- info: "bg-blue-200"
24
- }, {})
25
- .withTypography({
26
- fontFamily: { mono: true },
27
- textAppearance: { secondary: true },
28
- })
29
- .build();
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- import { componentBuilder } from "./../utils/componentBuilder";
3
- import { BaseComponentProps } from "./props/props";
4
-
5
- export const Divider: React.FC<BaseComponentProps> = (props) =>
6
- componentBuilder(props, "div", "bg-gray-200 w-full h-px")
7
- .build();
@@ -1 +0,0 @@
1
- @import "tailwindcss";
@@ -1,102 +0,0 @@
1
- import React from 'react';
2
- import { GridProps, LayoutComponentProps, ColProps, RowProps } from "./props/props";
3
- import { componentBuilder } from "../utils/componentBuilder";
4
-
5
- const centeredClasses = {
6
- centered: "items-center justify-center",
7
- vCentered: "items-center",
8
- hCentered: "justify-center"
9
- }
10
-
11
- export const Section: React.FC<LayoutComponentProps> = (props) =>
12
- componentBuilder(props, "section", "w-full flex flex-col items-start")
13
- .withCentered(centeredClasses)
14
- .withSizes({
15
- xs: "py-6 max-lg:py-4 max-md:py-2",
16
- sm: "py-8 max-lg:py-6 max-md:py-4",
17
- md: "py-10 max-lg:py-8 max-md:py-6",
18
- lg: "py-12 max-lg:py-10 max-md:py-8",
19
- xl: "py-14 max-lg:py-12 max-md:py-10",
20
- })
21
- .withSizes({
22
- xs: "px-4 max-lg:px-2 max-md:px-0",
23
- sm: "px-6 max-lg:px-6 max-md:px-2",
24
- md: "px-8 max-lg:px-6 max-md:px-4",
25
- lg: "px-10 max-lg:px-8 max-md:px-6",
26
- xl: "px-12 max-lg:px-10 max-md:px-8",
27
- })
28
- .build();
29
-
30
- export const Container: React.FC<LayoutComponentProps> = (props) =>
31
- componentBuilder(props, "div", "flex flex-col mx-auto w-full")
32
- .withCentered(centeredClasses)
33
- .withSizes({
34
- xs: "max-w-3xl gap-2 max-lg:gap-1",
35
- sm: "max-w-4xl gap-4 max-lg:gap-3 max-md:gap-2",
36
- md: "max-w-5xl gap-6 max-lg:gap-5 max-md:gap-4",
37
- lg: "max-w-6xl gap-8 max-lg:gap-7 max-md:gap-6",
38
- xl: "max-w-7xl gap-10 max-lg:gap-9 max-md:gap-8",
39
- })
40
- .build();
41
-
42
- const commonGaps = {
43
- xs: "gap-1",
44
- sm: "gap-2 max-lg:gap-1",
45
- md: "gap-4 max-lg:gap-3 max-md:gap-2",
46
- lg: "gap-6 max-lg:gap-5 max-md:gap-4",
47
- xl: "gap-8 max-lg:gap-7 max-md:gap-6",
48
- }
49
-
50
- export const Col: React.FC<ColProps> = (props) =>
51
- componentBuilder(props, "div", "flex flex-col")
52
- .withGaps({ noGap: "gap-0" }, commonGaps)
53
- .withReverse({
54
- reverse: "flex-col-reverse"
55
- })
56
- .withCentered(centeredClasses)
57
- .build();
58
-
59
- export const Row: React.FC<RowProps> = (props) =>
60
- componentBuilder(props, "div", "flex flex-row")
61
- .withGaps({ noGap: "gap-0" }, commonGaps)
62
- .withReverse({
63
- reverse: "flex-row-reverse"
64
- })
65
- .withCentered(centeredClasses)
66
- .withBreakpoints({
67
- xsCol: "max-xs:flex-col",
68
- smCol: "max-sm:flex-col",
69
- mdCol: "max-md:flex-col",
70
- lgCol: "max-lg:flex-col",
71
- xlCol: "max-xl:flex-col"
72
- })
73
- .withBooleanProps({
74
- justifyStart: "justify-start",
75
- justifyEnd: "justify-end",
76
- justifyCenter: "justify-center",
77
- justifyBetween: "justify-between",
78
- justifyAround: "justify-around",
79
- justifyEvenly: "justify-evenly",
80
- justifyStretch: "justify-stretch",
81
- justifyBaseline: "justify-baseline",
82
- })
83
- .build();
84
-
85
- const gridGaps = {
86
- xs: "gap-2",
87
- sm: "gap-4 max-lg:gap-2",
88
- md: "gap-6 max-lg:gap-4",
89
- lg: "gap-8 max-lg:gap-6 max-md:gap-4",
90
- xl: "gap-10 max-lg:gap-8 max-md:gap-6",
91
- }
92
-
93
- export const Grid3: React.FC<GridProps> = (props) =>
94
- componentBuilder(props, "div", "w-full grid grid-cols-3 max-lg:grid-cols-2 max-md:grid-cols-1")
95
- .withGaps({ noGap: "gap-0" }, gridGaps)
96
- .build();
97
-
98
- export const Grid4: React.FC<GridProps> = (props) =>
99
- componentBuilder(props, "div", "w-full grid grid-cols-4 max-lg:grid-cols-3 max-md:grid-cols-2 max-sm:grid-cols-1")
100
- .withGaps({ noGap: "gap-0" }, gridGaps)
101
- .build();
102
-
@@ -1,51 +0,0 @@
1
- export const fontWeightClasses = {
2
- thin: "font-thin",
3
- extralight: "font-extralight",
4
- light: "font-light",
5
- normal: "font-normal",
6
- medium: "font-medium",
7
- semibold: "font-semibold",
8
- bold: "font-bold",
9
- extrabold: "font-extrabold",
10
- black: "font-black",
11
- }
12
-
13
- export const fontStyleClasses = {
14
- italic: "italic",
15
- notItalic: "not-italic",
16
- }
17
-
18
- export const fontFamilyClasses = {
19
- sans: "font-sans",
20
- serif: "font-serif",
21
- mono: "font-mono",
22
- }
23
-
24
- export const textDecorationClasses = {
25
- underline: "underline",
26
- lineThrough: "line-through",
27
- noUnderline: "no-underline",
28
- overline: "overline",
29
- }
30
-
31
- export const textTransformClasses = {
32
- uppercase: "uppercase",
33
- lowercase: "lowercase",
34
- capitalize: "capitalize",
35
- normalCase: "normal-case",
36
- }
37
-
38
- export const textAppearanceClasses = {
39
- default: "text-(--text-color-default)",
40
- primary: "text-(--text-color-primary)",
41
- secondary: "text-(--text-color-secondary)",
42
- tertiary: "text-(--text-color-tertiary)",
43
- muted: "text-(--text-color-muted)",
44
- link: "text-(--text-color-link)",
45
-
46
- accent: "text-(--text-color-accent)",
47
- success: "text-(--text-color-success)",
48
- danger: "text-(--text-color-danger)",
49
- warning: "text-(--text-color-warning)",
50
- info: "text-(--text-color-info)",
51
- }
@@ -1,128 +0,0 @@
1
- export interface SizeProps {
2
- xs?: boolean;
3
- sm?: boolean;
4
- md?: boolean;
5
- lg?: boolean;
6
- xl?: boolean;
7
- }
8
-
9
- export interface FontFamilyProps {
10
- sans?: boolean;
11
- serif?: boolean;
12
- mono?: boolean;
13
- }
14
-
15
- export interface FontWeightProps {
16
- thin?: boolean;
17
- extralight?: boolean;
18
- light?: boolean;
19
- normal?: boolean;
20
- medium?: boolean;
21
- semibold?: boolean;
22
- bold?: boolean;
23
- extrabold?: boolean;
24
- black?: boolean;
25
- }
26
-
27
- export interface FontStyleProps {
28
- italic?: boolean;
29
- notItalic?: boolean;
30
- }
31
-
32
- export interface TextDecorationProps {
33
- underline?: boolean;
34
- lineThrough?: boolean;
35
- noUnderline?: boolean;
36
- overline?: boolean;
37
- }
38
-
39
- export interface TextTransformProps {
40
- uppercase?: boolean;
41
- lowercase?: boolean;
42
- capitalize?: boolean;
43
- normalCase?: boolean;
44
- }
45
-
46
- export interface TextAppearanceProps {
47
- muted?: boolean;
48
- link?: boolean;
49
- }
50
-
51
- export interface CommonAppearanceProps {
52
- default?: boolean;
53
- accent?: boolean;
54
- primary?: boolean;
55
- secondary?: boolean;
56
- tertiary?: boolean;
57
- success?: boolean;
58
- danger?: boolean;
59
- warning?: boolean;
60
- info?: boolean;
61
- }
62
-
63
- export interface BreakpointProps {
64
- xsCol?: boolean;
65
- smCol?: boolean;
66
- mdCol?: boolean;
67
- lgCol?: boolean;
68
- xlCol?: boolean;
69
- }
70
-
71
- export interface HideProps {
72
- xsHide?: boolean;
73
- smHide?: boolean;
74
- mdHide?: boolean;
75
- lgHide?: boolean;
76
- xlHide?: boolean;
77
- }
78
-
79
- export interface PositionProps {
80
- relative?: boolean;
81
- absolute?: boolean;
82
- fixed?: boolean;
83
- sticky?: boolean;
84
- static?: boolean;
85
- }
86
-
87
- export interface TagProps {
88
- tag?: React.ElementType | string;
89
- }
90
-
91
- export interface ReverseProps {
92
- reverse?: boolean;
93
- }
94
-
95
- export interface GapProps {
96
- noGap?: boolean;
97
- }
98
-
99
- export interface CenteredProps {
100
- centered?: boolean;
101
- vCentered?: boolean;
102
- hCentered?: boolean;
103
- }
104
-
105
- export interface JustifyProps {
106
- justifyStart?: boolean;
107
- justifyEnd?: boolean;
108
- justifyCenter?: boolean;
109
- justifyBetween?: boolean;
110
- justifyAround?: boolean;
111
- justifyEvenly?: boolean;
112
- justifyStretch?: boolean;
113
- justifyBaseline?: boolean;
114
- }
115
-
116
- export type BaseComponentProps = TagProps & Partial<SizeProps & HideProps & PositionProps> & React.HTMLProps<HTMLElement>;
117
-
118
- export type LayoutComponentProps = BaseComponentProps & ReverseProps & CenteredProps;
119
-
120
- export type FontProps = FontWeightProps & FontStyleProps & TextDecorationProps & TextTransformProps & FontFamilyProps & TextAppearanceProps & CommonAppearanceProps;
121
-
122
- export type TypographyComponentProps = BaseComponentProps & FontProps;
123
-
124
- export type GridProps = BaseComponentProps & GapProps;
125
-
126
- export type RowProps = BaseComponentProps & GapProps & ReverseProps & CenteredProps & BreakpointProps & JustifyProps;
127
-
128
- export type ColProps = BaseComponentProps & GapProps & ReverseProps & CenteredProps;
@@ -1,19 +0,0 @@
1
- import { CommonAppearanceProps, FontFamilyProps, FontStyleProps, FontWeightProps, TextAppearanceProps, TextDecorationProps, TextTransformProps } from "./props/props";
2
-
3
- export type CommonAppearanceSettings = { [key in keyof CommonAppearanceProps]: boolean; };
4
-
5
- export type FontFamilySettings = { [key in keyof FontFamilyProps]: boolean; };
6
- export type FontWeightSettings = { [key in keyof FontWeightProps]: boolean; };
7
- export type FontStyleSettings = { [key in keyof FontStyleProps]: boolean; };
8
- export type TextAppearanceSettings = { [key in keyof TextAppearanceProps & CommonAppearanceProps]: boolean; };
9
- export type TextDecorationSettings = { [key in keyof TextDecorationProps]: boolean; };
10
- export type TextTransformSettings = { [key in keyof TextTransformProps]: boolean; };
11
-
12
- export type TypographySettings = {
13
- fontFamily?: FontFamilySettings;
14
- fontWeight?: FontWeightSettings;
15
- fontStyle?: FontStyleSettings;
16
- textAppearance?: TextAppearanceSettings;
17
- textDecoration?: TextDecorationSettings;
18
- textTransform?: TextTransformSettings;
19
- };
@@ -1,97 +0,0 @@
1
- import React from 'react';
2
- import { componentBuilder } from "../utils/componentBuilder";
3
- import { TypographyComponentProps } from "./props/props";
4
-
5
- export const PageTitle: React.FC<TypographyComponentProps> = (props) =>
6
- componentBuilder(props, "h1")
7
- .withSizes({
8
- xs: "text-3xl",
9
- sm: "text-4xl",
10
- md: "text-5xl",
11
- lg: "text-6xl",
12
- xl: "text-7xl",
13
- })
14
- .withTypography({
15
- fontWeight: { semibold: true }
16
- })
17
- .build();
18
-
19
- export const SectionTitle: React.FC<TypographyComponentProps> = (props) =>
20
- componentBuilder(props, "h2")
21
- .withSizes({
22
- xs: "text-2xl",
23
- sm: "text-3xl",
24
- md: "text-4xl",
25
- lg: "text-5xl",
26
- xl: "text-6xl",
27
- })
28
- .withTypography({
29
- fontWeight: { semibold: true }
30
- })
31
- .build();
32
-
33
- export const Title: React.FC<TypographyComponentProps> = (props) =>
34
- componentBuilder(props, "h3")
35
- .withSizes({
36
- xs: "text-lg",
37
- sm: "text-xl",
38
- md: "text-2xl",
39
- lg: "text-3xl",
40
- xl: "text-4xl",
41
- })
42
- .withTypography({
43
- fontWeight: { semibold: true }
44
- })
45
- .build();
46
-
47
- export const Text: React.FC<TypographyComponentProps> = (props) =>
48
- componentBuilder(props, "p", "p-0 m-0")
49
- .withSizes({
50
- xs: "text-xs",
51
- sm: "text-sm",
52
- md: "text-md",
53
- lg: "text-lg",
54
- xl: "text-xl",
55
- })
56
- .withTypography({
57
- textAppearance: { secondary: true }
58
- })
59
- .build();
60
-
61
- export const Link: React.FC<TypographyComponentProps> = (props) =>
62
- componentBuilder(props, "a", "hover:underline")
63
- .withSizes({
64
- xs: "text-xs",
65
- sm: "text-sm",
66
- md: "text-md",
67
- lg: "text-lg",
68
- xl: "text-xl",
69
- })
70
- .withTypography({
71
- textAppearance: { link: true }
72
- })
73
- .build();
74
-
75
- export const ListItem: React.FC<TypographyComponentProps> = (props) =>
76
- componentBuilder(props, "li")
77
- .withSizes({
78
- xs: "text-xs",
79
- sm: "text-sm",
80
- md: "text-md",
81
- lg: "text-lg",
82
- xl: "text-xl",
83
- })
84
- .withTypography({})
85
- .build();
86
-
87
- export const List: React.FC<TypographyComponentProps> = (props) =>
88
- componentBuilder(props, "ul", "list-disc list-inside")
89
- .withSizes({
90
- xs: "text-xs",
91
- sm: "text-sm",
92
- md: "text-md",
93
- lg: "text-lg",
94
- xl: "text-xl",
95
- })
96
- .withTypography({})
97
- .build();
@@ -1,124 +0,0 @@
1
- import { twMerge } from "tailwind-merge";
2
- import { BaseComponentProps, BreakpointProps, CenteredProps, CommonAppearanceProps, FontFamilyProps, FontStyleProps, FontWeightProps, GapProps, HideProps, PositionProps, ReverseProps, ColProps, RowProps, TextAppearanceProps, TextDecorationProps, TextTransformProps, SizeProps } from "../ui/props/props";
3
- import { fontFamilyClasses, fontStyleClasses, fontWeightClasses, textAppearanceClasses, textDecorationClasses, textTransformClasses } from "../ui/props/commonValues";
4
- import { CommonAppearanceSettings, FontFamilySettings, FontStyleSettings, FontWeightSettings, TextAppearanceSettings, TextDecorationSettings, TextTransformSettings, TypographySettings } from "../ui/settings";
5
-
6
- function getBooleanClass<T extends Record<string, boolean | undefined>>(
7
- props: T,
8
- classes?: Record<keyof T, string>,
9
- fallbackKey?: keyof T
10
- ): string {
11
- if (!classes) return "";
12
- for (const key in props) {
13
- if (Object.prototype.hasOwnProperty.call(props, key) && props[key]) {
14
- return classes[key] ?? "";
15
- }
16
- }
17
- return fallbackKey ? classes[fallbackKey] ?? "" : "";
18
- }
19
-
20
- export function componentBuilder(
21
- baseProps: BaseComponentProps,
22
- defaultTag: string,
23
- baseClasses?: string
24
- ) {
25
- const extraClasses: string[] = [];
26
- const { className, children, tag, ...other } = baseProps;
27
- const otherProps: (typeof other) & Partial<ReverseProps & CenteredProps & GapProps & RowProps & ColProps> = { ...other };
28
- const propsToRemove: string[] = []
29
-
30
- const registerKeys = (keys: string[]) => {
31
- keys.forEach((key) => propsToRemove.push(key));
32
- };
33
-
34
- const withBooleanProps = <T extends Record<string, string>>(
35
- propMap: Record<keyof T, string>,
36
- fallbackKey?: keyof T,
37
- settings?: { [key: string]: boolean }
38
- ) => {
39
- // Build a subset of props from otherProps for the keys in the map.
40
- const propsSubset: Partial<Record<keyof T, boolean>> = {} as Partial<Record<keyof T, boolean>>;
41
- const keys = Object.keys(propMap) as (keyof T)[];
42
- keys.forEach((key) => {
43
- if (key in otherProps) {
44
- propsSubset[key] = otherProps[key as keyof typeof otherProps];
45
- }
46
- });
47
-
48
- if (settings) {
49
- const settingsClass = getBooleanClass(settings || {}, propMap);
50
- extraClasses.push(settingsClass);
51
- }
52
-
53
- // Compute the class.
54
- const newClass = getBooleanClass(propsSubset, propMap, fallbackKey);
55
- extraClasses.push(newClass);
56
-
57
- // Register all keys found in the map.
58
- registerKeys(keys as string[]);
59
- return builder;
60
- };
61
-
62
- function finalize(): React.ReactElement {
63
- const Tag = tag || defaultTag;
64
- const merged = twMerge(baseClasses, ...extraClasses, className);
65
-
66
- propsToRemove.forEach(key => delete otherProps[key as keyof typeof otherProps])
67
-
68
- return (
69
- <Tag className={merged} {...otherProps}>
70
- {children}
71
- </Tag>
72
- );
73
- }
74
-
75
- const builder = {
76
- withBooleanProps,
77
-
78
- withSizes: (sizeMap: Record<keyof SizeProps, string>) => withBooleanProps(sizeMap, "md"),
79
- withBreakpoints: (breakpointMap: Record<keyof BreakpointProps, string>) => withBooleanProps(breakpointMap),
80
- withReverse: (reverseMap: Record<keyof ReverseProps, string>) => withBooleanProps(reverseMap),
81
- withCentered: (centeredMap: Record<keyof CenteredProps, string>) => withBooleanProps(centeredMap),
82
- withHide: (hideMap: Record<keyof HideProps, string>) => withBooleanProps(hideMap),
83
- withPosition: (positionMap: Record<keyof PositionProps, string>) => withBooleanProps(positionMap),
84
- withFontWeight: (fontWeight: Record<keyof FontWeightProps, string>, settings: FontWeightSettings) => withBooleanProps(fontWeight, undefined, settings),
85
- withFontStyle: (fontStyle: Record<keyof FontStyleProps, string>, settings: FontStyleSettings) => withBooleanProps(fontStyle, undefined, settings),
86
- withFontFamily: (fontFamily: Record<keyof FontFamilyProps, string>, settings: FontFamilySettings) => withBooleanProps(fontFamily, undefined, settings),
87
- withTextDecoration: (textDecoration: Record<keyof TextDecorationProps, string>, settings: TextDecorationSettings) => withBooleanProps(textDecoration, undefined, settings),
88
- withTextTransform: (textTransform: Record<keyof TextTransformProps, string>, settings: TextTransformSettings) => withBooleanProps(textTransform, undefined, settings),
89
- withTextAppearance: (appearance: Record<keyof TextAppearanceProps & CommonAppearanceProps, string>, settings: TextAppearanceSettings) => withBooleanProps(appearance, "default", settings),
90
-
91
- withGaps: (gapMap: Record<keyof GapProps, string>, sizeMap: Record<keyof SizeProps, string>) =>
92
- otherProps.noGap !== undefined && otherProps.noGap ? withBooleanProps(gapMap) : builder.withSizes(sizeMap),
93
-
94
- withTypography: (settings: TypographySettings) => builder
95
- .withFontFamily(fontFamilyClasses, settings?.fontFamily ?? {})
96
- .withFontStyle(fontStyleClasses, settings?.fontStyle ?? {})
97
- .withFontWeight(fontWeightClasses, settings?.fontWeight ?? {})
98
- .withTextDecoration(textDecorationClasses, settings?.textDecoration ?? {})
99
- .withTextTransform(textTransformClasses, settings?.textTransform ?? {})
100
- .withTextAppearance(textAppearanceClasses, settings?.textAppearance ?? {}),
101
-
102
- withAppearance: (appearance: Record<keyof CommonAppearanceProps, string>, settings: CommonAppearanceSettings) => withBooleanProps(appearance, "default", settings),
103
-
104
- build() {
105
- builder.withHide({
106
- xsHide: "max-xs:hidden",
107
- smHide: "max-sm:hidden",
108
- mdHide: "max-md:hidden",
109
- lgHide: "max-lg:hidden",
110
- xlHide: "max-xl:hidden"
111
- })
112
- builder.withPosition({
113
- relative: "relative",
114
- absolute: "absolute",
115
- fixed: "fixed",
116
- sticky: "sticky",
117
- static: "static"
118
- })
119
- return finalize();
120
- },
121
- };
122
-
123
- return builder;
124
- }
package/src/index.ts DELETED
@@ -1,6 +0,0 @@
1
- export { Button } from "./components/ui/button";
2
- export { Badge } from "./components/ui/badge";
3
- export { Divider } from "./components/ui/divider";
4
- export { Chip } from "./components/ui/chip";
5
- export { Section, Container, Col, Row, Grid3, Grid4 } from "./components/ui/layout";
6
- export { Text, Title, Link, List, ListItem, SectionTitle, PageTitle } from "./components/ui/typography";
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "rootDir": "src/components/complex",
5
- "outDir": "dist/components/complex",
6
- "declarationDir": "dist/components/complex"
7
- },
8
- "include": [
9
- "src/components/complex/**/*"
10
- ]
11
- }
package/tsconfig.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2019",
4
- "module": "ESNext",
5
- "lib": ["DOM", "ESNext"],
6
- "jsx": "react-jsx",
7
- "declaration": true,
8
- "outDir": "dist",
9
- "moduleResolution": "node",
10
- "esModuleInterop": true,
11
- "skipLibCheck": true,
12
- "strict": true
13
- },
14
- "include": ["src"]
15
- }