buildgrid-ui 1.1.0-dev.8 → 1.1.0

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.
Files changed (128) hide show
  1. package/dist/blocks/help-carousel/help-carousel.d.ts +9 -0
  2. package/dist/blocks/help-carousel/index.d.ts +1 -0
  3. package/dist/blocks/index.d.ts +4 -0
  4. package/dist/blocks/month-navigator/index.d.ts +1 -0
  5. package/dist/blocks/month-navigator/month-navigator.d.ts +9 -0
  6. package/dist/blocks/pagination-controls/index.d.ts +1 -0
  7. package/dist/blocks/pagination-controls/pagination-controls.d.ts +7 -0
  8. package/dist/blocks/sidebar/index.d.ts +1 -0
  9. package/dist/blocks/sidebar/sidebar.d.ts +26 -0
  10. package/dist/buildgrid-ui.es.js +10607 -4877
  11. package/dist/buildgrid-ui.umd.js +134 -63
  12. package/dist/components/adaptive-input/index.d.ts +1 -0
  13. package/dist/components/alert-dialog/alert-dialog.d.ts +20 -0
  14. package/dist/components/alert-dialog/index.d.ts +1 -0
  15. package/dist/components/autocomplete/autocomplete.d.ts +1 -0
  16. package/dist/components/badge/badge.d.ts +1 -1
  17. package/dist/components/button/button.d.ts +1 -1
  18. package/dist/components/calendar/calendar.d.ts +8 -0
  19. package/dist/components/calendar/index.d.ts +1 -0
  20. package/dist/components/currency-input/currency-input.d.ts +1 -1
  21. package/dist/components/dialog/dialog.d.ts +19 -0
  22. package/dist/components/dialog/index.d.ts +1 -0
  23. package/dist/components/index.d.ts +16 -1
  24. package/dist/components/label/index.d.ts +1 -0
  25. package/dist/components/label/label.d.ts +5 -0
  26. package/dist/components/navigation-menu/index.d.ts +1 -0
  27. package/dist/components/navigation-menu/navigation-menu.d.ts +12 -0
  28. package/dist/components/pagination/index.d.ts +1 -0
  29. package/dist/components/pagination/pagination.d.ts +28 -0
  30. package/dist/components/radio-group/index.d.ts +1 -0
  31. package/dist/components/radio-group/radio-group.d.ts +5 -0
  32. package/dist/components/select/index.d.ts +1 -0
  33. package/dist/components/select/select.d.ts +13 -0
  34. package/dist/components/table/index.d.ts +1 -0
  35. package/dist/components/table/table.d.ts +10 -0
  36. package/dist/components/tabs/index.d.ts +1 -0
  37. package/dist/components/tabs/tabs.d.ts +7 -0
  38. package/dist/components/textarea/index.d.ts +1 -0
  39. package/dist/components/textarea/textarea.d.ts +3 -0
  40. package/dist/components/toaster/index.d.ts +2 -0
  41. package/dist/components/toaster/toaster.d.ts +9 -0
  42. package/dist/components/toggle/index.d.ts +1 -0
  43. package/dist/components/toggle/toggle.d.ts +12 -0
  44. package/dist/components/toggle-group/index.d.ts +1 -0
  45. package/dist/components/toggle-group/toggle-group.d.ts +12 -0
  46. package/dist/components/tooltip/index.d.ts +1 -0
  47. package/dist/components/tooltip/tooltip.d.ts +7 -0
  48. package/dist/index.d.ts +3 -1
  49. package/dist/lib/hooks/index.d.ts +5 -0
  50. package/dist/lib/hooks/use-debounce.d.ts +2 -0
  51. package/dist/lib/hooks/use-dialog.d.ts +30 -0
  52. package/dist/lib/hooks/use-media-query.d.ts +1 -0
  53. package/dist/lib/hooks/use-mobile.d.ts +1 -0
  54. package/dist/lib/hooks/use-pwa-install.d.ts +7 -0
  55. package/dist/lib/utils/index.d.ts +2 -0
  56. package/package.json +19 -2
  57. package/.editorconfig +0 -5
  58. package/.eslintrc.json +0 -3
  59. package/.github/workflows/release.yml +0 -25
  60. package/.husky/commit-msg +0 -1
  61. package/.prettierignore +0 -6
  62. package/.prettierrc +0 -6
  63. package/.releaserc.json +0 -40
  64. package/.storybook/main.ts +0 -26
  65. package/.storybook/preview.ts +0 -15
  66. package/CHANGELOG.md +0 -53
  67. package/commitlint.config.js +0 -3
  68. package/components.json +0 -21
  69. package/dist/components/adaptative-input/index.d.ts +0 -1
  70. package/dist/lib/index.d.ts +0 -2
  71. package/eslint.config.mjs +0 -13
  72. package/postcss.config.js +0 -6
  73. package/src/components/adaptative-input/adaptative-input.stories.tsx +0 -31
  74. package/src/components/adaptative-input/adaptative-input.tsx +0 -66
  75. package/src/components/adaptative-input/index.ts +0 -1
  76. package/src/components/autocomplete/autocomplete.stories.tsx +0 -84
  77. package/src/components/autocomplete/autocomplete.tsx +0 -136
  78. package/src/components/autocomplete/index.ts +0 -1
  79. package/src/components/avatar/avatar.stories.tsx +0 -29
  80. package/src/components/avatar/avatar.tsx +0 -48
  81. package/src/components/avatar/index.ts +0 -1
  82. package/src/components/badge/badge.stories.tsx +0 -30
  83. package/src/components/badge/badge.tsx +0 -34
  84. package/src/components/badge/index.ts +0 -1
  85. package/src/components/button/button.stories.tsx +0 -62
  86. package/src/components/button/button.tsx +0 -82
  87. package/src/components/button/index.ts +0 -1
  88. package/src/components/card/card.stories.tsx +0 -41
  89. package/src/components/card/card.tsx +0 -61
  90. package/src/components/card/index.ts +0 -1
  91. package/src/components/checkbox/checkbox.stories.tsx +0 -36
  92. package/src/components/checkbox/checkbox.tsx +0 -28
  93. package/src/components/checkbox/index.ts +0 -1
  94. package/src/components/currency-input/currency-input.stories.tsx +0 -28
  95. package/src/components/currency-input/currency-input.tsx +0 -93
  96. package/src/components/currency-input/index.ts +0 -1
  97. package/src/components/dropdown-menu/dropdown-menu.stories.tsx +0 -90
  98. package/src/components/dropdown-menu/dropdown-menu.tsx +0 -192
  99. package/src/components/dropdown-menu/index.ts +0 -1
  100. package/src/components/index.ts +0 -15
  101. package/src/components/input/index.ts +0 -1
  102. package/src/components/input/input.stories.tsx +0 -22
  103. package/src/components/input/input.tsx +0 -41
  104. package/src/components/password-input/index.ts +0 -1
  105. package/src/components/password-input/password-input.stories.tsx +0 -26
  106. package/src/components/password-input/password-input.tsx +0 -98
  107. package/src/components/popover/index.ts +0 -1
  108. package/src/components/popover/popover.stories.tsx +0 -32
  109. package/src/components/popover/popover.tsx +0 -30
  110. package/src/components/progress/index.ts +0 -1
  111. package/src/components/progress/progress.stories.tsx +0 -21
  112. package/src/components/progress/progress.tsx +0 -26
  113. package/src/components/skeleton/index.ts +0 -1
  114. package/src/components/skeleton/skeleton.stories.tsx +0 -24
  115. package/src/components/skeleton/skeleton.tsx +0 -19
  116. package/src/components/switch/index.ts +0 -1
  117. package/src/components/switch/switch.stories.tsx +0 -21
  118. package/src/components/switch/switch.tsx +0 -26
  119. package/src/index.ts +0 -2
  120. package/src/lib/index.ts +0 -2
  121. package/src/lib/utils/cn.ts +0 -6
  122. package/src/lib/utils/formatters.ts +0 -55
  123. package/src/styles/tailwind.css +0 -66
  124. package/tailwind.config.js +0 -57
  125. package/tsconfig.app.json +0 -10
  126. package/tsconfig.json +0 -29
  127. package/vite.config.ts +0 -34
  128. /package/dist/components/{adaptative-input/adaptative-input.d.ts → adaptive-input/adaptive-input.d.ts} +0 -0
package/CHANGELOG.md DELETED
@@ -1,53 +0,0 @@
1
- # [1.1.0-alpha.6](https://github.com/adrianomaringolo/buildgrid-ui/compare/v1.1.0-alpha.5...v1.1.0-alpha.6) (2025-01-03)
2
-
3
-
4
- ### Features
5
-
6
- * **avatar:** add Avatar component with fallback and image support ([893a16e](https://github.com/adrianomaringolo/buildgrid-ui/commit/893a16e8c45a35f56f91d1a11e1615cb4fa35347))
7
- * **dropdown-menu:** add DropdownMenu component with stories and functionality ([5006e9d](https://github.com/adrianomaringolo/buildgrid-ui/commit/5006e9dd4c41354cda4f664f2169b6fd77a75e87))
8
-
9
- # [1.1.0-alpha.5](https://github.com/adrianomaringolo/buildgrid-ui/compare/v1.1.0-alpha.4...v1.1.0-alpha.5) (2025-01-03)
10
-
11
-
12
- ### Features
13
-
14
- * **adaptive-input:** add AdaptiveInput component with masking functionality and stories ([d2d9794](https://github.com/adrianomaringolo/buildgrid-ui/commit/d2d97944b150163d69342ddb68e6e188283f0348))
15
- * **autocomplete:** add Autocomplete component with stories and functionality ([c35b4ae](https://github.com/adrianomaringolo/buildgrid-ui/commit/c35b4ae634654b1451ab0f3936f1d757ff70e122))
16
- * **input:** add Input component with stories ([8078ee7](https://github.com/adrianomaringolo/buildgrid-ui/commit/8078ee7c0e9b986007d89096d08065300c36b7c9))
17
- * **popover:** add Popover component with stories ([32373a1](https://github.com/adrianomaringolo/buildgrid-ui/commit/32373a13c235e0899b9c332f42b48f13c704f82c))
18
-
19
- # [1.1.0-alpha.4](https://github.com/adrianomaringolo/buildgrid-ui/compare/v1.1.0-alpha.3...v1.1.0-alpha.4) (2025-01-02)
20
-
21
-
22
- ### Features
23
-
24
- * add Checkbox component and related stories ([7e2d66b](https://github.com/adrianomaringolo/buildgrid-ui/commit/7e2d66b7a19f8ddb5a6a5e5f827f1df552977113))
25
-
26
- # [1.1.0-alpha.3](https://github.com/adrianomaringolo/buildgrid-ui/compare/v1.1.0-alpha.2...v1.1.0-alpha.3) (2025-01-02)
27
-
28
-
29
- ### Features
30
-
31
- * add new components ([acc2538](https://github.com/adrianomaringolo/buildgrid-ui/commit/acc253867cbadec11b61c3d9dcf1b5151ac3096b))
32
-
33
- # [1.1.0-alpha.2](https://github.com/adrianomaringolo/buildgrid-ui/compare/v1.1.0-alpha.1...v1.1.0-alpha.2) (2025-01-02)
34
-
35
-
36
- ### Features
37
-
38
- * add Badge component and related stories ([4106287](https://github.com/adrianomaringolo/buildgrid-ui/commit/41062872c2807cfa14494c9cab1f2b8fe506d246))
39
-
40
- # [1.1.0-alpha.1](https://github.com/adrianomaringolo/buildgrid-ui/compare/v1.0.0...v1.1.0-alpha.1) (2025-01-02)
41
-
42
-
43
- ### Features
44
-
45
- * adding shadcn configuration ([5841434](https://github.com/adrianomaringolo/buildgrid-ui/commit/584143402fad7aa19e477693d2a4727f5625e430))
46
- * enhance Button component stories with props and update export ([69292b3](https://github.com/adrianomaringolo/buildgrid-ui/commit/69292b3d467dd5ed8eacf521e9c5f89e465af323))
47
-
48
- # 1.0.0 (2025-01-02)
49
-
50
-
51
- ### Features
52
-
53
- * add Button component with Storybook integration and initial configuration ([bbc4e9a](https://github.com/adrianomaringolo/buildgrid-ui/commit/bbc4e9a54e3ea295622c8598d51576f3cddd1b3d))
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- extends: ["@commitlint/config-conventional"],
3
- };
package/components.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "$schema": "https://ui.shadcn.com/schema.json",
3
- "style": "default",
4
- "rsc": false,
5
- "tsx": true,
6
- "tailwind": {
7
- "config": "tailwind.config.js",
8
- "css": "src/styles/tailwind.css",
9
- "baseColor": "neutral",
10
- "cssVariables": true,
11
- "prefix": ""
12
- },
13
- "aliases": {
14
- "components": "@/components",
15
- "utils": "@/lib/utils",
16
- "ui": "@/components/ui",
17
- "lib": "@/lib",
18
- "hooks": "@/hooks"
19
- },
20
- "iconLibrary": "lucide"
21
- }
@@ -1 +0,0 @@
1
- export * from './adaptative-input';
@@ -1,2 +0,0 @@
1
- export * from './utils/cn';
2
- export * from './utils/formatters';
package/eslint.config.mjs DELETED
@@ -1,13 +0,0 @@
1
- import path from "node:path";
2
- import { fileURLToPath } from "node:url";
3
- import js from "@eslint/js";
4
- import { FlatCompat } from "@eslint/eslintrc";
5
-
6
- const __filename = fileURLToPath(import.meta.url);
7
- const __dirname = path.dirname(__filename);
8
- const compat = new FlatCompat({
9
- baseDirectory: __dirname,
10
- recommendedConfig: js.configs.recommended,
11
- allConfig: js.configs.all
12
- });
13
- export default [...compat.extends("next/core-web-vitals", "next/typescript", "prettier")];
package/postcss.config.js DELETED
@@ -1,6 +0,0 @@
1
- module.exports = {
2
- plugins: {
3
- tailwindcss: {},
4
- autoprefixer: {},
5
- },
6
- };
@@ -1,31 +0,0 @@
1
- // organize-imports-ignore
2
- import React from 'react'
3
- import type { Meta, StoryObj } from '@storybook/react'
4
-
5
- import { AdaptiveInput } from './adaptative-input'
6
- import { HelpCircle, Phone, User } from 'lucide-react'
7
-
8
- const meta: Meta<typeof AdaptiveInput> = {
9
- title: 'Components/input/adaptiveInput',
10
- component: AdaptiveInput,
11
- }
12
-
13
- export default meta
14
- type Story = StoryObj<typeof AdaptiveInput>
15
-
16
- const Template = () => {
17
- return (
18
- <div className="w-64">
19
- <AdaptiveInput
20
- leftIcon={<Phone className="w-4 h-4" />}
21
- rightIcon={<HelpCircle className="w-4 h-4" />}
22
- mask="+00 0000-0000"
23
- />
24
- </div>
25
- )
26
- }
27
-
28
- export const Default: Story = {
29
- render: Template.bind({}),
30
- args: {},
31
- }
@@ -1,66 +0,0 @@
1
- import { cn } from '@/lib'
2
- import * as React from 'react'
3
- import { Input, InputProps } from '../input'
4
-
5
- export interface AdaptiveInputProps extends InputProps {
6
- leftIcon?: React.ReactNode
7
- rightIcon?: React.ReactNode
8
- mask?: string // New prop for the mask
9
- }
10
-
11
- const applyMask = (value: string, mask: string): string => {
12
- const cleanValue = value.replace(/\D/g, '')
13
- let maskedValue = ''
14
- let maskIndex = 0
15
- let valueIndex = 0
16
-
17
- while (maskIndex < mask.length && valueIndex < cleanValue.length) {
18
- if (mask[maskIndex] === '0') {
19
- maskedValue += cleanValue[valueIndex]
20
- valueIndex++
21
- } else {
22
- maskedValue += mask[maskIndex]
23
- }
24
- maskIndex++
25
- }
26
-
27
- return maskedValue
28
- }
29
-
30
- const AdaptiveInput = React.forwardRef<HTMLInputElement, AdaptiveInputProps>(
31
- ({ className, leftIcon, rightIcon, mask, onChange, ...props }, ref) => {
32
- const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
33
- const input = e.target
34
- if (mask) {
35
- const maskedValue = applyMask(input.value, mask)
36
- input.value = maskedValue
37
- }
38
- onChange?.(e) // Call the original onChange if provided
39
- }
40
-
41
- return (
42
- <div className="relative w-fit">
43
- {leftIcon && (
44
- <div className="absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground">
45
- {leftIcon}
46
- </div>
47
- )}
48
- <Input
49
- className={cn(leftIcon && 'pl-8', rightIcon && 'pr-8', className)}
50
- ref={ref}
51
- onInput={handleInputChange} // Attach the input handler
52
- {...props}
53
- />
54
- {rightIcon && (
55
- <div className="absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground">
56
- {rightIcon}
57
- </div>
58
- )}
59
- </div>
60
- )
61
- },
62
- )
63
-
64
- AdaptiveInput.displayName = 'AdaptiveInput'
65
-
66
- export { AdaptiveInput }
@@ -1 +0,0 @@
1
- export * from './adaptative-input'
@@ -1,84 +0,0 @@
1
- // organize-imports-ignore
2
- import React from 'react'
3
- import type { Meta, StoryObj } from '@storybook/react'
4
-
5
- import { Autocomplete } from './autocomplete'
6
-
7
- const meta: Meta<typeof Autocomplete> = {
8
- title: 'Components/input/autocomplete',
9
- component: Autocomplete,
10
- }
11
-
12
- export default meta
13
- type Story = StoryObj<typeof Autocomplete>
14
-
15
- // list of 50 names of countries
16
- const options = [
17
- 'United States',
18
- 'Canada',
19
- 'Argentina',
20
- 'Brazil',
21
- 'Chile',
22
- 'Colombia',
23
- 'Ecuador',
24
- 'Peru',
25
- 'Uruguay',
26
- 'Venezuela',
27
- 'Australia',
28
- 'China',
29
- 'India',
30
- 'Indonesia',
31
- 'Japan',
32
- 'Korea',
33
- 'Malaysia',
34
- 'Philippines',
35
- 'Singapore',
36
- 'Thailand',
37
- 'Vietnam',
38
- 'Austria',
39
- 'Belgium',
40
- 'Croatia',
41
- 'Denmark',
42
- 'Finland',
43
- 'France',
44
- 'Germany',
45
- 'Greece',
46
- 'Hungary',
47
- 'Ireland',
48
- 'Italy',
49
- 'Netherlands',
50
- 'Norway',
51
- 'Poland',
52
- 'Portugal',
53
- 'Romania',
54
- 'Russia',
55
- 'Spain',
56
- 'Sweden',
57
- 'Switzerland',
58
- 'Turkey',
59
- 'Ukraine',
60
- 'United Kingdom',
61
- 'Egypt',
62
- 'Nigeria',
63
- 'South Africa',
64
- 'Kenya',
65
- ]
66
-
67
- const Template = () => {
68
- const [value, setValue] = React.useState('')
69
- return (
70
- <div className="w-80">
71
- <Autocomplete
72
- value={value}
73
- onChange={(value) => setValue(value)}
74
- options={options.map((option) => ({ value: option, label: option }))}
75
- />
76
- <p className="mt-4">Selected value: {value}</p>
77
- </div>
78
- )
79
- }
80
-
81
- export const Default: Story = {
82
- render: Template.bind({}),
83
- args: {},
84
- }
@@ -1,136 +0,0 @@
1
- import { Search } from 'lucide-react'
2
- import { useState } from 'react'
3
-
4
- import { cn } from '@/lib'
5
- import { AdaptiveInput } from '../adaptative-input'
6
- import { Popover, PopoverContent, PopoverTrigger } from '../popover'
7
-
8
- interface Option {
9
- value: string
10
- label: string
11
- }
12
-
13
- interface AutoCompleteProps {
14
- value?: string
15
- onChange?: (value: string) => void
16
- options: Option[]
17
- className?: string
18
- placeholder?: string
19
- emptyMessage?: string
20
- }
21
-
22
- export function Autocomplete(props: AutoCompleteProps) {
23
- const {
24
- value = '',
25
- onChange,
26
- options: staticOptions,
27
- className,
28
- placeholder = 'Search...',
29
- emptyMessage = 'Nothing found',
30
- } = props
31
-
32
- const [query, setQuery] = useState(value)
33
- const [suggestions, setSuggestions] = useState<Option[]>(staticOptions)
34
- const [selectedIndex, setSelectedIndex] = useState(-1)
35
- const [isFocused, setIsFocused] = useState(false)
36
-
37
- const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
38
- const newValue = e.target.value
39
- setQuery(newValue)
40
- onChange?.(newValue)
41
- setSelectedIndex(-1)
42
- setIsFocused(true)
43
-
44
- if (newValue.trim() === '') {
45
- setSuggestions(staticOptions)
46
- } else {
47
- setSuggestions(
48
- staticOptions.filter((option) =>
49
- option.label.toLowerCase().includes(newValue.toLowerCase()),
50
- ),
51
- )
52
- }
53
- }
54
-
55
- const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
56
- if (e.key === 'ArrowDown') {
57
- e.preventDefault()
58
- setSelectedIndex((prev) => (prev < suggestions.length - 1 ? prev + 1 : prev))
59
- } else if (e.key === 'ArrowUp') {
60
- e.preventDefault()
61
- setSelectedIndex((prev) => (prev > 0 ? prev - 1 : -1))
62
- } else if (e.key === 'Enter' && selectedIndex >= 0) {
63
- const selectedOption = suggestions[selectedIndex]
64
- setQuery(selectedOption.label)
65
- onChange?.(selectedOption.value)
66
- setSuggestions([])
67
- setSelectedIndex(-1)
68
- setIsFocused(false)
69
- } else if (e.key === 'Escape') {
70
- setSuggestions([])
71
- setSelectedIndex(-1)
72
- }
73
- }
74
-
75
- const handleSuggestionClick = (option: Option) => {
76
- setIsFocused(false)
77
- setQuery(option.label)
78
- onChange?.(option.value)
79
- setSuggestions(staticOptions)
80
- setSelectedIndex(-1)
81
- }
82
-
83
- const handleFocus = () => {
84
- setIsFocused(true)
85
- }
86
-
87
- const handleBlur = () => {
88
- setIsFocused(false)
89
- }
90
-
91
- return (
92
- <Popover open={isFocused}>
93
- <PopoverTrigger asChild>
94
- <div className="relative w-full">
95
- <AdaptiveInput
96
- type="text"
97
- placeholder={placeholder}
98
- value={query}
99
- onChange={handleInputChange}
100
- onKeyDown={handleKeyDown}
101
- onClick={handleFocus}
102
- onFocus={handleFocus}
103
- onBlur={handleBlur}
104
- className={cn('pr-10', className)}
105
- aria-label="Search field"
106
- aria-autocomplete="list"
107
- aria-controls="suggestions-list"
108
- aria-expanded={suggestions.length > 0}
109
- leftIcon={<Search className="w-4 h-4" />}
110
- />
111
- </div>
112
- </PopoverTrigger>
113
- <PopoverContent className="p-0 w-[var(--radix-popover-trigger-width)] max-h-96 overflow-y-auto">
114
- {suggestions.length > 0 ? (
115
- <ul id="suggestions-list" role="listbox">
116
- {suggestions.map((option, index) => (
117
- <li
118
- key={option.value}
119
- className={`px-4 py-2 cursor-pointer hover:bg-muted ${
120
- index === selectedIndex ? 'bg-muted' : ''
121
- }`}
122
- onClick={() => handleSuggestionClick(option)}
123
- role="option"
124
- aria-selected={index === selectedIndex}
125
- >
126
- {option.label}
127
- </li>
128
- ))}
129
- </ul>
130
- ) : (
131
- <span className="px-4 py-2 block">{emptyMessage}</span>
132
- )}
133
- </PopoverContent>
134
- </Popover>
135
- )
136
- }
@@ -1 +0,0 @@
1
- export * from './autocomplete'
@@ -1,29 +0,0 @@
1
- // organize-imports-ignore
2
- import React from 'react'
3
- import type { Meta, StoryObj } from '@storybook/react'
4
-
5
- import { Avatar, AvatarFallback, AvatarImage } from './avatar'
6
-
7
- const meta: Meta<typeof Avatar> = {
8
- component: Avatar,
9
- }
10
-
11
- export default meta
12
- type Story = StoryObj<typeof Avatar>
13
-
14
- const Template = () => {
15
- return (
16
- <Avatar className="w-24 h-24">
17
- <AvatarImage
18
- src="https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png?20150327203541"
19
- alt="User avatar"
20
- />
21
- <AvatarFallback>NS</AvatarFallback>
22
- </Avatar>
23
- )
24
- }
25
-
26
- export const Default: Story = {
27
- render: Template.bind({}),
28
- args: {},
29
- }
@@ -1,48 +0,0 @@
1
- import * as AvatarPrimitive from '@radix-ui/react-avatar'
2
- import * as React from 'react'
3
-
4
- import { cn } from '@/lib/utils/cn'
5
-
6
- const Avatar = React.forwardRef<
7
- React.ElementRef<typeof AvatarPrimitive.Root>,
8
- React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
9
- >(({ className, ...props }, ref) => (
10
- <AvatarPrimitive.Root
11
- ref={ref}
12
- className={cn(
13
- 'relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full',
14
- className,
15
- )}
16
- {...props}
17
- />
18
- ))
19
- Avatar.displayName = AvatarPrimitive.Root.displayName
20
-
21
- const AvatarImage = React.forwardRef<
22
- React.ElementRef<typeof AvatarPrimitive.Image>,
23
- React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
24
- >(({ className, ...props }, ref) => (
25
- <AvatarPrimitive.Image
26
- ref={ref}
27
- className={cn('aspect-square h-full w-full', className)}
28
- {...props}
29
- />
30
- ))
31
- AvatarImage.displayName = AvatarPrimitive.Image.displayName
32
-
33
- const AvatarFallback = React.forwardRef<
34
- React.ElementRef<typeof AvatarPrimitive.Fallback>,
35
- React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
36
- >(({ className, ...props }, ref) => (
37
- <AvatarPrimitive.Fallback
38
- ref={ref}
39
- className={cn(
40
- 'flex h-full w-full items-center justify-center rounded-full bg-muted',
41
- className,
42
- )}
43
- {...props}
44
- />
45
- ))
46
- AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName
47
-
48
- export { Avatar, AvatarFallback, AvatarImage }
@@ -1 +0,0 @@
1
- export * from './avatar'
@@ -1,30 +0,0 @@
1
- // organize-imports-ignore
2
- import React from 'react'
3
- import type { Meta, StoryObj } from '@storybook/react'
4
-
5
- import { Badge, BadgeProps, badgeVariants } from './badge'
6
-
7
- const meta: Meta<typeof Badge> = {
8
- component: Badge,
9
- }
10
-
11
- export default meta
12
- type Story = StoryObj<typeof Badge>
13
-
14
- const Template = (args: BadgeProps) => {
15
- const variants = ['default', 'secondary', 'destructive', 'outline']
16
- return (
17
- <div className="flex gap-2">
18
- {Object.values(variants).map((variant) => (
19
- <Badge {...args} variant={variant as BadgeProps['variant']}>
20
- {variant}
21
- </Badge>
22
- ))}
23
- </div>
24
- )
25
- }
26
-
27
- export const Default: Story = {
28
- render: Template.bind({}),
29
- args: {},
30
- }
@@ -1,34 +0,0 @@
1
- import { cva, type VariantProps } from 'class-variance-authority'
2
- import * as React from 'react'
3
-
4
- import { cn } from '@/lib'
5
-
6
- const badgeVariants = cva(
7
- 'inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',
8
- {
9
- variants: {
10
- variant: {
11
- default:
12
- 'border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80',
13
- secondary:
14
- 'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80',
15
- destructive:
16
- 'border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80',
17
- outline: 'text-foreground',
18
- },
19
- },
20
- defaultVariants: {
21
- variant: 'default',
22
- },
23
- },
24
- )
25
-
26
- export interface BadgeProps
27
- extends React.HTMLAttributes<HTMLDivElement>,
28
- VariantProps<typeof badgeVariants> {}
29
-
30
- function Badge({ className, variant, ...props }: BadgeProps) {
31
- return <div className={cn(badgeVariants({ variant }), className)} {...props} />
32
- }
33
-
34
- export { Badge, badgeVariants }
@@ -1 +0,0 @@
1
- export * from './badge'
@@ -1,62 +0,0 @@
1
- // organize-imports-ignore
2
- import React from 'react'
3
- import type { Meta, StoryObj } from '@storybook/react'
4
- import { Button, ButtonProps } from './button'
5
-
6
- const meta: Meta<typeof Button> = {
7
- component: Button,
8
- }
9
-
10
- export default meta
11
- type Story = StoryObj<typeof Button>
12
-
13
- const variants: Array<ButtonProps['variant']> = [
14
- 'default',
15
- 'secondary',
16
- 'destructive',
17
- 'outline',
18
- 'ghost',
19
- 'link',
20
- ]
21
-
22
- const Template = (args: ButtonProps) => {
23
- return (
24
- <div className="flex gap-2 flex-wrap">
25
- {Object.values(variants).map((variant) => (
26
- <Button
27
- {...args}
28
- variant={variant as ButtonProps['variant']}
29
- className="capitalize"
30
- >
31
- {variant}
32
- </Button>
33
- ))}
34
- </div>
35
- )
36
- }
37
-
38
- export const Default: Story = {
39
- render: Template.bind({}),
40
- args: {},
41
- }
42
-
43
- const TemplateIsLoading = () => {
44
- return (
45
- <div className="flex gap-2 flex-wrap">
46
- {Object.values(variants).map((variant) => (
47
- <Button
48
- isLoading
49
- variant={variant as ButtonProps['variant']}
50
- className="capitalize"
51
- >
52
- {variant}
53
- </Button>
54
- ))}
55
- </div>
56
- )
57
- }
58
-
59
- export const Loading: Story = {
60
- render: TemplateIsLoading.bind({}),
61
- args: {},
62
- }