-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UI package with Shadcn components and use them on apps
- Loading branch information
1 parent
cafa9a1
commit 5704168
Showing
23 changed files
with
1,332 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { | ||
Button, | ||
HoverCard, | ||
HoverCardContent, | ||
HoverCardTrigger, | ||
} from '@mfe-tutorial/ui'; | ||
import { CalendarDays } from 'lucide-react'; | ||
|
||
export function HoverCardDemo() { | ||
return ( | ||
<HoverCard> | ||
<HoverCardTrigger asChild> | ||
<Button variant="link">@mfe-tutorial</Button> | ||
</HoverCardTrigger> | ||
<HoverCardContent className="w-80"> | ||
<div className="flex justify-between space-x-4"> | ||
<div className="space-y-1"> | ||
<h4 className="text-sm font-semibold">@nextjs</h4> | ||
<p className="text-sm"> | ||
The React Framework – created and maintained by @vercel. | ||
</p> | ||
<div className="flex items-center pt-2"> | ||
<CalendarDays className="w-4 h-4 mr-2 opacity-70" />{' '} | ||
<span className="text-xs text-muted-foreground"> | ||
Joined December 2021 | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
</HoverCardContent> | ||
</HoverCard> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
@import '../../../packages/ui/src/styles.css'; | ||
|
||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
/* You can add global styles to this file, and also import other style files */ | ||
/* You can add global styles to this file, and also import other style files */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { | ||
ContextMenu, | ||
ContextMenuCheckboxItem, | ||
ContextMenuContent, | ||
ContextMenuItem, | ||
ContextMenuLabel, | ||
ContextMenuRadioGroup, | ||
ContextMenuRadioItem, | ||
ContextMenuSeparator, | ||
ContextMenuShortcut, | ||
ContextMenuSub, | ||
ContextMenuSubContent, | ||
ContextMenuSubTrigger, | ||
ContextMenuTrigger, | ||
} from '@mfe-tutorial/ui'; | ||
|
||
export function ContextMenuDemo() { | ||
return ( | ||
<ContextMenu> | ||
<ContextMenuTrigger className="flex h-[150px] w-[300px] items-center justify-center rounded-md border border-dashed text-sm"> | ||
Right click here | ||
</ContextMenuTrigger> | ||
<ContextMenuContent className="w-64"> | ||
<ContextMenuItem inset> | ||
Back | ||
<ContextMenuShortcut>⌘[</ContextMenuShortcut> | ||
</ContextMenuItem> | ||
<ContextMenuItem disabled inset> | ||
Forward | ||
<ContextMenuShortcut>⌘]</ContextMenuShortcut> | ||
</ContextMenuItem> | ||
<ContextMenuItem inset> | ||
Reload | ||
<ContextMenuShortcut>⌘R</ContextMenuShortcut> | ||
</ContextMenuItem> | ||
<ContextMenuSub> | ||
<ContextMenuSubTrigger inset>More Tools</ContextMenuSubTrigger> | ||
<ContextMenuSubContent className="w-48"> | ||
<ContextMenuItem> | ||
Save Page As... | ||
<ContextMenuShortcut>⇧⌘S</ContextMenuShortcut> | ||
</ContextMenuItem> | ||
<ContextMenuItem>Create Shortcut...</ContextMenuItem> | ||
<ContextMenuItem>Name Window...</ContextMenuItem> | ||
<ContextMenuSeparator /> | ||
<ContextMenuItem>Developer Tools</ContextMenuItem> | ||
</ContextMenuSubContent> | ||
</ContextMenuSub> | ||
<ContextMenuSeparator /> | ||
<ContextMenuCheckboxItem checked> | ||
Show Bookmarks Bar | ||
<ContextMenuShortcut>⌘⇧B</ContextMenuShortcut> | ||
</ContextMenuCheckboxItem> | ||
<ContextMenuCheckboxItem>Show Full URLs</ContextMenuCheckboxItem> | ||
<ContextMenuSeparator /> | ||
<ContextMenuRadioGroup value="pedro"> | ||
<ContextMenuLabel inset>People</ContextMenuLabel> | ||
<ContextMenuSeparator /> | ||
<ContextMenuRadioItem value="pedro"> | ||
Pedro Duarte | ||
</ContextMenuRadioItem> | ||
<ContextMenuRadioItem value="colm">Colm Tuite</ContextMenuRadioItem> | ||
</ContextMenuRadioGroup> | ||
</ContextMenuContent> | ||
</ContextMenu> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"$schema": "https://ui.shadcn.com/schema.json", | ||
"style": "default", | ||
"rsc": false, | ||
"tsx": true, | ||
"tailwind": { | ||
"config": "tailwind.config.js", | ||
"css": "packages/ui/src/styles.css", | ||
"baseColor": "slate", | ||
"cssVariables": true, | ||
"prefix": "" | ||
}, | ||
"aliases": { | ||
"components": "packages/ui/src/components", | ||
"utils": "packages/ui/src/lib/utils" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { default as Button, type BaseButtonProps } from './button'; | ||
export * from './ui'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { cva, type VariantProps } from 'class-variance-authority'; | ||
import * as React from 'react'; | ||
|
||
import { cn } from '../../lib/utils'; | ||
|
||
const badgeVariants = cva( | ||
'inline-flex items-center rounded-full 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', | ||
{ | ||
variants: { | ||
variant: { | ||
default: | ||
'border-transparent bg-primary text-primary-foreground hover:bg-primary/80', | ||
secondary: | ||
'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80', | ||
destructive: | ||
'border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80', | ||
outline: 'text-foreground', | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: 'default', | ||
}, | ||
} | ||
); | ||
|
||
export interface BadgeProps | ||
extends React.HTMLAttributes<HTMLDivElement>, | ||
VariantProps<typeof badgeVariants> {} | ||
|
||
function Badge({ className, variant, ...props }: BadgeProps) { | ||
return ( | ||
<div className={cn(badgeVariants({ variant }), className)} {...props} /> | ||
); | ||
} | ||
|
||
export { Badge, badgeVariants }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Slot } from '@radix-ui/react-slot'; | ||
import { cva, type VariantProps } from 'class-variance-authority'; | ||
import * as React from 'react'; | ||
|
||
import { cn } from '../../lib/utils'; | ||
|
||
const buttonVariants = cva( | ||
'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50', | ||
{ | ||
variants: { | ||
variant: { | ||
default: 'bg-primary text-primary-foreground hover:bg-primary/90', | ||
destructive: | ||
'bg-destructive text-destructive-foreground hover:bg-destructive/90', | ||
outline: | ||
'border border-input bg-background hover:bg-accent hover:text-accent-foreground', | ||
secondary: | ||
'bg-secondary text-secondary-foreground hover:bg-secondary/80', | ||
ghost: 'hover:bg-accent hover:text-accent-foreground', | ||
link: 'text-primary underline-offset-4 hover:underline', | ||
}, | ||
size: { | ||
default: 'h-10 px-4 py-2', | ||
sm: 'h-9 rounded-md px-3', | ||
lg: 'h-11 rounded-md px-8', | ||
icon: 'h-10 w-10', | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: 'default', | ||
size: 'default', | ||
}, | ||
} | ||
); | ||
|
||
export interface ButtonProps | ||
extends React.ButtonHTMLAttributes<HTMLButtonElement>, | ||
VariantProps<typeof buttonVariants> { | ||
asChild?: boolean; | ||
} | ||
|
||
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>( | ||
({ className, variant, size, asChild = false, ...props }, ref) => { | ||
const Comp = asChild ? Slot : 'button'; | ||
|
||
return ( | ||
<Comp | ||
className={cn(buttonVariants({ variant, size, className }))} | ||
ref={ref} | ||
{...props} | ||
/> | ||
); | ||
} | ||
); | ||
|
||
Button.displayName = 'Button'; | ||
|
||
export { Button, buttonVariants }; |
Oops, something went wrong.