Skip to content

Commit 614a85d

Browse files
authored
chore(web_common): add more shared components (#5243)
1 parent 1a9edc7 commit 614a85d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2233
-432
lines changed

pnpm-lock.yaml

Lines changed: 331 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/common/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ tsconfig.tsbuildinfo
44

55
*storybook.log
66
storybook-static
7+
**/__snapshots__/**
8+
**/__screenshots__/**

web/common/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
"devDependencies": {
55
"@eslint/js": "^9.31.0",
66
"@radix-ui/react-slot": "^1.2.3",
7+
"@radix-ui/react-tooltip": "^1.2.8",
78
"@storybook/addon-docs": "^9.1.2",
89
"@storybook/addon-essentials": "^9.0.0-alpha.12",
910
"@storybook/addon-onboarding": "^9.1.2",
1011
"@storybook/react-vite": "^9.1.2",
12+
"@storybook/test": "^8.6.14",
1113
"@tailwindcss/typography": "^0.5.16",
1214
"@testing-library/dom": "^10.4.1",
1315
"@testing-library/jest-dom": "^6.6.3",
@@ -17,20 +19,23 @@
1719
"@types/react-dom": "^18.3.7",
1820
"@vitejs/plugin-react": "^4.7.0",
1921
"@vitest/browser": "^3.2.4",
22+
"@xyflow/react": "^12.8.4",
2023
"autoprefixer": "^10.4.21",
2124
"class-variance-authority": "^0.7.1",
2225
"clsx": "^2.1.1",
2326
"eslint": "^9.31.0",
2427
"eslint-plugin-react-hooks": "^5.2.0",
2528
"eslint-plugin-storybook": "^9.1.2",
2629
"globals": "^16.3.0",
30+
"lucide-react": "^0.542.0",
2731
"playwright": "^1.54.1",
2832
"postcss": "^8.5.6",
2933
"react": "^18.3.1",
3034
"react-dom": "^18.3.1",
3135
"storybook": "^9.1.2",
3236
"syncpack": "^13.0.4",
3337
"tailwind-merge": "^3.3.1",
38+
"tailwind-scrollbar": "^4.0.2",
3439
"tailwindcss": "^3.4.17",
3540
"typescript": "^5.8.3",
3641
"typescript-eslint": "^8.38.0",
@@ -62,9 +67,12 @@
6267
"module": "dist/sqlmesh-common.es.js",
6368
"peerDependencies": {
6469
"@radix-ui/react-slot": "^1.2.3",
70+
"@radix-ui/react-tooltip": "^1.2.8",
6571
"@tailwindcss/typography": "^0.5.16",
72+
"@xyflow/react": "^12.8.4",
6673
"class-variance-authority": "^0.7.1",
6774
"clsx": "^2.1.1",
75+
"lucide-react": "^0.542.0",
6876
"react": "^18.3.1",
6977
"react-dom": "^18.3.1",
7078
"tailwind-merge": "^3.3.1",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
:root {
2-
--color-badge-background: var(--color-gray-100);
2+
--color-badge-background: var(--color-neutral-100);
33
--color-badge-foreground: var(--color-prose);
44
}

web/common/src/components/Badge/Badge.stories.tsx

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
import type { Meta, StoryObj } from '@storybook/react-vite'
22

3-
import { EnumShape, EnumSize } from '@/types/enums'
3+
import type { Shape, Size } from '@/types'
44
import { Badge } from './Badge'
55

66
const meta: Meta<typeof Badge> = {
77
title: 'Components/Badge',
88
component: Badge,
9-
tags: ['autodocs'],
10-
argTypes: {
11-
size: {
12-
control: { type: 'select' },
13-
options: Object.values(EnumSize),
14-
},
15-
shape: {
16-
control: { type: 'select' },
17-
options: Object.values(EnumShape),
18-
},
19-
children: { control: 'text' },
20-
},
219
}
2210

2311
export default meta
@@ -29,10 +17,13 @@ export const Default: Story = {
2917
},
3018
}
3119

20+
const sizes: Size[] = ['2xs', 'xs', 's', 'm', 'l', 'xl', '2xl']
21+
const shapes: Shape[] = ['square', 'round', 'pill']
22+
3223
export const Sizes: Story = {
3324
render: args => (
3425
<div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
35-
{Object.values(EnumSize).map(size => (
26+
{sizes.map(size => (
3627
<Badge
3728
key={size}
3829
size={size}
@@ -51,7 +42,7 @@ export const Sizes: Story = {
5142
export const Shapes: Story = {
5243
render: args => (
5344
<div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
54-
{Object.values(EnumShape).map(shape => (
45+
{shapes.map(shape => (
5546
<Badge
5647
key={shape}
5748
shape={shape}
@@ -78,32 +69,32 @@ export const Colors: Story = {
7869
}}
7970
>
8071
<Badge
81-
size={EnumSize.S}
82-
shape={EnumShape.Pill}
72+
size="s"
73+
shape="pill"
8374
className="bg-[red] text-light"
8475
{...args}
8576
>
8677
Primary Badge
8778
</Badge>
8879
<Badge
89-
size={EnumSize.S}
90-
shape={EnumShape.Pill}
80+
size="s"
81+
shape="pill"
9182
className="bg-[lightblue] text-prose"
9283
{...args}
9384
>
9485
Secondary Badge
9586
</Badge>
9687
<Badge
97-
size={EnumSize.S}
98-
shape={EnumShape.Round}
88+
size="s"
89+
shape="round"
9990
className="bg-[green] text-light"
10091
{...args}
10192
>
10293
Failed Badge
10394
</Badge>
10495
<Badge
105-
size={EnumSize.XXS}
106-
shape={EnumShape.Round}
96+
size="2xs"
97+
shape="round"
10798
className="bg-[orange] text-light"
10899
{...args}
109100
>

web/common/src/components/Badge/Badge.test.tsx

Lines changed: 0 additions & 58 deletions
This file was deleted.

web/common/src/components/Badge/Badge.tsx

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
import { Slot } from '@radix-ui/react-slot'
2-
import { type VariantProps } from 'class-variance-authority'
32
import React from 'react'
43

5-
import { type Size, type Shape } from '@/types/enums'
4+
import type { Shape, Size } from '@/types'
65
import { cn } from '@/utils'
7-
import { badgeVariants } from './help'
6+
import { cva } from 'class-variance-authority'
87

98
import './Badge.css'
109

11-
export interface BadgeProps
12-
extends React.HTMLAttributes<HTMLSpanElement>,
13-
VariantProps<typeof badgeVariants> {
10+
export interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
1411
asChild?: boolean
1512
size?: Size
1613
shape?: Shape
@@ -30,3 +27,33 @@ export const Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(
3027
},
3128
)
3229
Badge.displayName = 'Badge'
30+
31+
const size: Record<Size, string> = {
32+
'2xs': 'h-5 px-2 text-2xs leading-none rounded-2xs',
33+
xs: 'h-6 px-2 text-2xs rounded-xs',
34+
s: 'h-7 px-3 text-xs rounded-sm',
35+
m: 'h-8 px-4 rounded-md',
36+
l: 'h-9 px-4 rounded-lg',
37+
xl: 'h-10 px-4 rounded-xl',
38+
'2xl': 'h-11 px-6 rounded-2xl',
39+
}
40+
41+
const shape: Record<Shape, string> = {
42+
square: 'rounded-none',
43+
round: 'rounded-inherit',
44+
pill: 'rounded-full',
45+
}
46+
47+
const badgeVariants = cva(
48+
'bg-badge-background text-badge-foreground font-mono inline-flex align-middle items-center justify-center gap-2 leading-none whitespace-nowrap font-semibold',
49+
{
50+
variants: {
51+
size,
52+
shape,
53+
},
54+
defaultVariants: {
55+
size: 's',
56+
shape: 'round',
57+
},
58+
},
59+
)

web/common/src/components/Badge/help.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
:root {
2+
--color-button-primary-background: var(--color-action);
3+
--color-button-primary-foreground: var(--color-light);
4+
--color-button-primary-hover: var(--color-action-hover);
5+
--color-button-primary-active: var(--color-action-active);
6+
7+
--color-button-secondary-background: var(--color-neutral-100);
8+
--color-button-secondary-foreground: var(--color-prose);
9+
--color-button-secondary-hover: var(--color-neutral-125);
10+
--color-button-secondary-active: var(--color-neutral-150);
11+
12+
--color-button-alternative-background: var(--color-light);
13+
--color-button-alternative-foreground: var(--color-prose);
14+
--color-button-alternative-hover: var(--color-neutral-125);
15+
--color-button-alternative-active: var(--color-neutral-150);
16+
17+
--color-button-destructive-background: var(--color-neutral-100);
18+
--color-button-destructive-foreground: var(--color-destructive-foreground);
19+
--color-button-destructive-hover: var(--color-neutral-125);
20+
--color-button-destructive-active: var(--color-neutral-150);
21+
22+
--color-button-danger-background: var(--color-destructive);
23+
--color-button-danger-foreground: var(--color-light);
24+
--color-button-danger-hover: var(--color-destructive-hover);
25+
--color-button-danger-active: var(--color-destructive-active);
26+
27+
--color-button-transparent-background: transparent;
28+
--color-button-transparent-foreground: var(--color-prose);
29+
--color-button-secondary-hover: var(--color-neutral-125);
30+
--color-button-secondary-active: var(--color-neutral-150);
31+
}

0 commit comments

Comments
 (0)