Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phosphor icons experiments #1386

Closed
wants to merge 68 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
4eb63e7
install/upgrade dependencies & configure shadcn/ui
BrickheadJohnny Jun 27, 2024
f2e1010
use ts for tailwind config
BrickheadJohnny Jun 27, 2024
71a186f
add basic `layout.tsx`
BrickheadJohnny Jun 27, 2024
88fae3b
fix: remove top-level `/app` folder & add playground page
BrickheadJohnny Jun 27, 2024
fc83d9c
v2 add next theme (#1325)
dominik-stumpf Jun 27, 2024
d474773
feat: `Card` component (#1326)
BrickheadJohnny Jun 27, 2024
8d024c8
feat: `Dialog` component (#1328)
BrickheadJohnny Jun 27, 2024
a32ceb6
add shadcn button and style adjustments (#1327)
dominik-stumpf Jun 27, 2024
3a9323c
build: revert sourcing on postinstall
dominik-stumpf Jun 27, 2024
c69176d
fix(DialogExample): add `asChild` prop to trigger
BrickheadJohnny Jun 27, 2024
ea661c7
feat(Dialog): add focus management props
BrickheadJohnny Jun 28, 2024
156b4d2
feat(Dialog): export `DialogCloseButton` component
BrickheadJohnny Jun 28, 2024
46f8618
fix: update `--muted-foreground` variable
BrickheadJohnny Jun 29, 2024
7edc914
fix(ThemeToggle): make the buttons smaller
BrickheadJohnny Jun 29, 2024
d8d321d
Storybook (#1332)
BrickheadJohnny Jun 29, 2024
f6694f4
feat: add tooltip (#1335)
dominik-stumpf Jul 1, 2024
0a923e6
feat: `Toast` component & `useToast` hook (#1333)
BrickheadJohnny Jul 1, 2024
544146d
feat: `AlertDialog` component (#1337)
BrickheadJohnny Jul 1, 2024
773c2f7
Merge remote-tracking branch 'origin' into shadcn-ui
dominik-stumpf Jul 1, 2024
7a54835
Merge branch 'main' into shadcn-ui
BrickheadJohnny Jul 2, 2024
5ae1590
Merge branch 'main' into shadcn-ui
BrickheadJohnny Jul 2, 2024
e837fff
`Dialog` improvements (#1351)
BrickheadJohnny Jul 3, 2024
0e6572a
Merge branch 'main' into shadcn-ui
BrickheadJohnny Jul 4, 2024
e9635f8
fix(AlertDialog.stories): import types only
BrickheadJohnny Jul 4, 2024
64ac97b
fix(useToast): eslint issue
BrickheadJohnny Jul 4, 2024
da54c40
feat: `Form` component (#1358)
BrickheadJohnny Jul 5, 2024
25c0d32
feat: `Badge` component
BrickheadJohnny Jul 8, 2024
b1bf522
feat: `DropdownMenu` component (#1359)
BrickheadJohnny Jul 8, 2024
a525c4b
Merge branch 'main' into shadcn-ui
BrickheadJohnny Jul 9, 2024
a400f6d
chore: change default theme to dark
dominik-stumpf Jul 9, 2024
163c8a9
Merge branch 'main' into shadcn-ui
BrickheadJohnny Jul 10, 2024
08601ab
Merge branch 'main' into shadcn-ui
BrickheadJohnny Jul 10, 2024
39fdd57
feat: add anchor component (#1362)
dominik-stumpf Jul 10, 2024
399161c
chore: merge main branch
dominik-stumpf Jul 10, 2024
c26854d
style: apply biome check
dominik-stumpf Jul 10, 2024
0d79c4b
feat: add header (#1329)
dominik-stumpf Jul 10, 2024
406b992
Merge branch 'main' of github.com:guildxyz/guild.xyz into shadcn-ui
dominik-stumpf Jul 10, 2024
fa8b9dc
style: apply biome check
dominik-stumpf Jul 10, 2024
870188b
feat: add avatar and separator
dominik-stumpf Jul 10, 2024
aa75541
chore: update team href
dominik-stumpf Jul 10, 2024
626b754
Merge branch 'main' into shadcn-ui
BrickheadJohnny Jul 11, 2024
7edde79
fix: ring colors
BrickheadJohnny Jul 11, 2024
4cf228c
fix(CardMotionWrapper): add easing functions
BrickheadJohnny Jul 11, 2024
e0d19dd
fix(Dialog): ring color
BrickheadJohnny Jul 11, 2024
10ef137
fix: fine-tune accent & border colors
BrickheadJohnny Jul 11, 2024
8b4b437
fix(SharedSocials): UI improvements
BrickheadJohnny Jul 11, 2024
d6e4fc5
fix(ThemeToggle): make it work in both pages & app router
BrickheadJohnny Jul 11, 2024
c6e62e3
fix: minor UI issues
BrickheadJohnny Jul 11, 2024
3aa6e44
fix(ConnectRequirementPlatformButton): use the new `Button` component
BrickheadJohnny Jul 11, 2024
4baf3fa
fix(RequirementConnectButton): accept `ButtonProps`
BrickheadJohnny Jul 11, 2024
7470a91
feat: add notifications (#1360)
dominik-stumpf Jul 11, 2024
3cc3cdc
feat: add compound layout component (#1363)
dominik-stumpf Jul 11, 2024
1260a27
fix(NavMenu): add create-guild
dovalid Jul 11, 2024
fcaba43
UI(NavMenu): whitespace impros, highlight current path
dovalid Jul 11, 2024
afa804e
fix(NavMenu): use the `usePathname` hook
BrickheadJohnny Jul 12, 2024
2aecad4
fix(ThemeToggle): remove `console.log`
BrickheadJohnny Jul 12, 2024
b9e602d
v2 explorer (#1330)
dominik-stumpf Jul 12, 2024
efca6a1
UI(Dialog): mobile style
dovalid Jul 12, 2024
19256a6
Merge branch 'main' of github.com:guildxyz/guild.xyz into shadcn-ui
dominik-stumpf Jul 12, 2024
3bee065
fix(css): darken dark mode skeleton color (#1379)
dominik-stumpf Jul 13, 2024
638a502
chore: delete linux related esbuild plugin (#1380)
dominik-stumpf Jul 13, 2024
0b114cc
notification fix and cleanup (#1377)
dominik-stumpf Jul 13, 2024
821b6f0
fix(layout): add `antialiased` class
BrickheadJohnny Jul 15, 2024
7b85870
fix(Dialog): close animation
BrickheadJohnny Jul 15, 2024
500f833
chore: import types & context from `/dist/lib/...`
BrickheadJohnny Jul 15, 2024
9697adb
chore: remove `* as React` imports
BrickheadJohnny Jul 15, 2024
e272944
Merge branch 'shadcn-ui' into phosphor-icons-experiments
BrickheadJohnny Jul 15, 2024
ebfa1d2
feat: add `usedExports: true` to webpack config
BrickheadJohnny Jul 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: Toast component & useToast hook (#1333)
* feat: `Toast` component & `useToast` hook

* refactor: simplify toast background color management

* fix: focus-visible styles

* cleanup: define screen size variables only once

* fix(Toast): add ring on focus-visible

* fix(useToast): rename variable in `forEach`

* fix(ci): address linux storybook error (#1336)

* fix(ci): address linux storybook error

* chore(deps): move esbuild to dev deps

---------

Co-authored-by: Dominik Stumpf <122315398+dominik-stumpf@users.noreply.github.com>
  • Loading branch information
BrickheadJohnny and dominik-stumpf authored Jul 1, 2024
commit 0a923e633cfa98a45bcd0dde7274eee941f4a65f
500 changes: 380 additions & 120 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-focus-scope": "^1.1.0",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-toast": "^1.2.1",
"@radix-ui/react-toggle": "^1.1.0",
"@radix-ui/react-toggle-group": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.2",
Expand Down Expand Up @@ -109,6 +110,7 @@
},
"devDependencies": {
"@chromatic-com/storybook": "^1.6.0",
"@esbuild/linux-x64": "^0.22.0",
"@hookform/devtools": "^4.3.0",
"@storybook/addon-essentials": "^8.1.11",
"@storybook/addon-interactions": "^8.1.11",
Expand Down
18 changes: 14 additions & 4 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@
--border: 240 6% 90%;
--input: var(--border);
--ring: 224 71.4% 4.1%;

--toast-success: 137 64% 98%;
--toast-error: 0 78% 98%;
--toast-warning: 40 79% 96%;
--toast-info: 218 80% 98%;

--sm: 640px;
--md: 768px;
--lg: 1024px;
--xl: 1280px;
}

:root[data-theme="dark"] {
Expand Down Expand Up @@ -96,10 +106,10 @@
--input: var(--border);
--ring: 240 0% 45%;

--sm: 640px;
--md: 768px;
--lg: 1024px;
--xl: 1280px;
--toast-success: 180 4% 35%;
--toast-error: 317 4% 35%;
--toast-warning: 30 6% 34%;
--toast-info: 226 7% 36%;
}

:root[data-theme="dark"] video,
Expand Down
76 changes: 76 additions & 0 deletions src/v2/components/ui/Toast.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import type { Meta, StoryObj } from "@storybook/react"

import { Button } from "./Button"
import { useToast } from "./hooks/useToast"
import { ToastAction, ToastActionElement, ToastProps } from "./Toast"
import { Toaster } from "./Toaster"

const ToastExample = (props: {
variant: ToastProps["variant"]
action?: ToastActionElement
}) => {
const { toast } = useToast()

return (
<Button
onClick={() =>
toast({
title: "Example toast",
description: "This is the toast's descriptions",
...props,
})
}
>
Show toast
</Button>
)
}

const meta: Meta = {
title: "Design system/Toast",
component: ToastExample,
decorators: [
(Story) => (
<>
<Story />
<Toaster />
</>
),
],
}

type Story = StoryObj<typeof ToastExample>

export const Info: Story = {
args: {
variant: "info",
},
}

export const Success: Story = {
args: {
variant: "success",
},
}

export const Warning: Story = {
args: {
variant: "warning",
},
}

export const Error: Story = {
args: {
variant: "error",
},
}

export const WithAction: Story = {
name: "With action",
args: {
variant: "info",
action: <ToastAction altText="Try again">Try again</ToastAction>,
},
}

export default meta
122 changes: 122 additions & 0 deletions src/v2/components/ui/Toast.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
"use client"

import * as ToastPrimitives from "@radix-ui/react-toast"
import { cva, type VariantProps } from "class-variance-authority"
import * as React from "react"

import { cn } from "@/lib/utils"
import { X } from "@phosphor-icons/react/dist/ssr"

const ToastProvider = ToastPrimitives.Provider

const ToastViewport = React.forwardRef<
React.ElementRef<typeof ToastPrimitives.Viewport>,
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>
>(({ className, ...props }, ref) => (
<ToastPrimitives.Viewport
ref={ref}
className={cn(
"fixed right-0 top-0 z-[100] flex max-h-screen w-full max-w-[min(420px,_100%)] flex-col gap-2 p-4 focus:outline-none",
className
)}
{...props}
/>
))
ToastViewport.displayName = ToastPrimitives.Viewport.displayName

const toastVariants = cva(
"bg-card text-foreground group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md p-4 pr-8 shadow-lg transition-transform data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-right-full data-[state=open]:sm:slide-in-from-right-full focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
{
variants: {
variant: {
info: "bg-toast-info",
error: "bg-toast-error",
success: "bg-toast-success",
warning: "bg-toast-warning",
},
},
defaultVariants: {
variant: "info",
},
}
)

const Toast = React.forwardRef<
React.ElementRef<typeof ToastPrimitives.Root>,
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> &
VariantProps<typeof toastVariants>
>(({ className, variant, ...props }, ref) => (
<ToastPrimitives.Root
ref={ref}
className={cn(toastVariants({ variant }), className)}
{...props}
/>
))
Toast.displayName = ToastPrimitives.Root.displayName

const ToastAction = React.forwardRef<
React.ElementRef<typeof ToastPrimitives.Action>,
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>
>(({ className, ...props }, ref) => (
<ToastPrimitives.Action
ref={ref}
className={cn(
"inline-flex h-8 w-max shrink-0 items-center justify-center rounded-md bg-secondary px-3 text-sm font-medium ring-offset-transparent transition-colors hover:bg-secondary-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 active:bg-secondary-active disabled:pointer-events-none disabled:opacity-50",
className
)}
{...props}
/>
))
ToastAction.displayName = ToastPrimitives.Action.displayName

const ToastClose = React.forwardRef<
React.ElementRef<typeof ToastPrimitives.Close>,
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>
>(({ className, ...props }, ref) => (
<ToastPrimitives.Close
ref={ref}
className={cn(
"absolute right-2 top-2 rounded-full p-1 text-foreground/50 opacity-0 ring-ring transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus-visible:ring-4 group-hover:opacity-100",
className
)}
toast-close=""
{...props}
>
<X weight="bold" className="h-4 w-4" />
</ToastPrimitives.Close>
))
ToastClose.displayName = ToastPrimitives.Close.displayName

const ToastTitle = React.forwardRef<
React.ElementRef<typeof ToastPrimitives.Title>,
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title>
>(({ className, ...props }, ref) => (
<ToastPrimitives.Title
ref={ref}
className={cn("font-bold", className)}
{...props}
/>
))
ToastTitle.displayName = ToastPrimitives.Title.displayName

const ToastDescription = React.forwardRef<
React.ElementRef<typeof ToastPrimitives.Description>,
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>
>((props, ref) => <ToastPrimitives.Description ref={ref} {...props} />)
ToastDescription.displayName = ToastPrimitives.Description.displayName

type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>

type ToastActionElement = React.ReactElement<typeof ToastAction>

export {
Toast,
ToastAction,
ToastClose,
ToastDescription,
ToastProvider,
ToastTitle,
ToastViewport,
type ToastActionElement,
type ToastProps,
}
33 changes: 33 additions & 0 deletions src/v2/components/ui/Toaster.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"use client"

import {
Toast,
ToastClose,
ToastDescription,
ToastProvider,
ToastTitle,
ToastViewport,
} from "@/components/ui/Toast"
import { useToast } from "@/components/ui/hooks/useToast"

export function Toaster() {
const { toasts } = useToast()

return (
<ToastProvider>
{toasts.map(function ({ id, title, description, action, ...props }) {
return (
<Toast key={id} {...props}>
<div className="flex flex-col gap-1">
{title && <ToastTitle>{title}</ToastTitle>}
{description && <ToastDescription>{description}</ToastDescription>}
{action && <div className="mt-1 flex gap-1">{action}</div>}
</div>
<ToastClose />
</Toast>
)
})}
<ToastViewport />
</ToastProvider>
)
}
2 changes: 1 addition & 1 deletion src/v2/components/ui/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const TooltipContent = React.forwardRef<
ref={ref}
sideOffset={sideOffset}
className={cn(
"bg-tooltip text-tooltip-foreground z-50 overflow-hidden rounded-xl px-3 py-1.5 text-sm shadow-md duration-0 animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
"z-50 overflow-hidden rounded-xl bg-tooltip px-3 py-1.5 text-sm text-tooltip-foreground shadow-md duration-0 animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className
)}
{...props}
Expand Down
Loading