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

refactor(docs): badge dx #3960

Merged
merged 4 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 31 additions & 0 deletions apps/docs/content/components/badge/a11y.raw.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {Badge, Button} from "@nextui-org/react";

export const NotificationIcon = ({size, height, width, ...props}) => {
return (
<svg
fill="none"
height={size || height || 24}
viewBox="0 0 24 24"
width={size || width || 24}
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<path
clipRule="evenodd"
d="M18.707 8.796c0 1.256.332 1.997 1.063 2.85.553.628.73 1.435.73 2.31 0 .874-.287 1.704-.863 2.378a4.537 4.537 0 01-2.9 1.413c-1.571.134-3.143.247-4.736.247-1.595 0-3.166-.068-4.737-.247a4.532 4.532 0 01-2.9-1.413 3.616 3.616 0 01-.864-2.378c0-.875.178-1.682.73-2.31.754-.854 1.064-1.594 1.064-2.85V8.37c0-1.682.42-2.781 1.283-3.858C7.861 2.942 9.919 2 11.956 2h.09c2.08 0 4.204.987 5.466 2.625.82 1.054 1.195 2.108 1.195 3.745v.426zM9.074 20.061c0-.504.462-.734.89-.833.5-.106 3.545-.106 4.045 0 .428.099.89.33.89.833-.025.48-.306.904-.695 1.174a3.635 3.635 0 01-1.713.731 3.795 3.795 0 01-1.008 0 3.618 3.618 0 01-1.714-.732c-.39-.269-.67-.694-.695-1.173z"
fill="currentColor"
fillRule="evenodd"
/>
</svg>
);
};

export default function App() {
return (
<Badge color="danger" content="99+" shape="circle">
<Button isIconOnly aria-label="more than 99 notifications" radius="full" variant="light">
<NotificationIcon size={24} />
</Button>
</Badge>
);
}
39 changes: 1 addition & 38 deletions apps/docs/content/components/badge/a11y.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,7 @@
export const NotificationIcon = `export const NotificationIcon = ({size, height, width, ...props}) => {
return (
<svg
fill="none"
height={size || height || 24}
viewBox="0 0 24 24"
width={size || width || 24}
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<path
clipRule="evenodd"
d="M18.707 8.796c0 1.256.332 1.997 1.063 2.85.553.628.73 1.435.73 2.31 0 .874-.287 1.704-.863 2.378a4.537 4.537 0 01-2.9 1.413c-1.571.134-3.143.247-4.736.247-1.595 0-3.166-.068-4.737-.247a4.532 4.532 0 01-2.9-1.413 3.616 3.616 0 01-.864-2.378c0-.875.178-1.682.73-2.31.754-.854 1.064-1.594 1.064-2.85V8.37c0-1.682.42-2.781 1.283-3.858C7.861 2.942 9.919 2 11.956 2h.09c2.08 0 4.204.987 5.466 2.625.82 1.054 1.195 2.108 1.195 3.745v.426zM9.074 20.061c0-.504.462-.734.89-.833.5-.106 3.545-.106 4.045 0 .428.099.89.33.89.833-.025.48-.306.904-.695 1.174a3.635 3.635 0 01-1.713.731 3.795 3.795 0 01-1.008 0 3.618 3.618 0 01-1.714-.732c-.39-.269-.67-.694-.695-1.173z"
fill='currentColor'
fillRule="evenodd"
/>
</svg>
);
};`;

const App = `import {Badge, Button} from "@nextui-org/react";
import {NotificationIcon} from "./NotificationIcon";

export default function App() {
return (
<Badge content="99+" shape="circle" color="danger">
<Button
radius="full"
isIconOnly
aria-label="more than 99 notifications"
variant="light"
>
<NotificationIcon size={24} />
</Button>
</Badge>
);
}`;
import App from "./a11y.raw.jsx?raw";

const react = {
"/App.jsx": App,
"/NotificationIcon.jsx": NotificationIcon,
};

export default {
Expand Down
26 changes: 26 additions & 0 deletions apps/docs/content/components/badge/colors.raw.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {Badge, Avatar} from "@nextui-org/react";

export default function App() {
return (
<div className="flex gap-3 items-center">
<Badge color="default" content="5">
<Avatar radius="md" src="https://i.pravatar.cc/150?u=a042f81f4e29026024d" />
</Badge>
<Badge color="primary" content="5">
<Avatar radius="md" src="https://i.pravatar.cc/150?u=a04258a2462d826712d" />
</Badge>
<Badge color="secondary" content="5">
<Avatar radius="md" src="https://i.pravatar.cc/300?u=a042581f4e29026709d" />
</Badge>
<Badge color="success" content="5">
<Avatar radius="md" src="https://i.pravatar.cc/150?u=a04258114e29026302d" />
</Badge>
<Badge color="warning" content="5">
<Avatar radius="md" src="https://i.pravatar.cc/150?u=a04258114e29026708c" />
</Badge>
<Badge color="danger" content="5">
<Avatar radius="md" src="https://i.pravatar.cc/150?u=a042581f4e29026024d" />
</Badge>
</div>
);
}
45 changes: 1 addition & 44 deletions apps/docs/content/components/badge/colors.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,4 @@
const App = `import {Badge, Avatar} from "@nextui-org/react";

export default function App() {
return (
<div className="flex gap-3 items-center">
<Badge content="5" color="default">
<Avatar
radius="md"
src="https://i.pravatar.cc/150?u=a042f81f4e29026024d"
/>
</Badge>
<Badge content="5" color="primary">
<Avatar
radius="md"
src="https://i.pravatar.cc/150?u=a04258a2462d826712d"
/>
</Badge>
<Badge content="5" color="secondary">
<Avatar
radius="md"
src="https://i.pravatar.cc/300?u=a042581f4e29026709d"
/>
</Badge>
<Badge content="5" color="success">
<Avatar
radius="md"
src="https://i.pravatar.cc/150?u=a04258114e29026302d"
/>
</Badge>
<Badge content="5" color="warning">
<Avatar
radius="md"
src="https://i.pravatar.cc/150?u=a04258114e29026708c"
/>
</Badge>
<Badge content="5" color="danger">
<Avatar
radius="md"
src="https://i.pravatar.cc/150?u=a042581f4e29026024d"
/>
</Badge>
</div>
);
}`;
import App from "./colors.raw.jsx?raw";

const react = {
"/App.jsx": App,
Expand Down
80 changes: 80 additions & 0 deletions apps/docs/content/components/badge/content-examples.raw.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import {Badge, Avatar} from "@nextui-org/react";

export const NotificationIcon = ({size, height, width, ...props}) => {
return (
<svg
fill="none"
height={size || height || 24}
viewBox="0 0 24 24"
width={size || width || 24}
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<path
clipRule="evenodd"
d="M18.707 8.796c0 1.256.332 1.997 1.063 2.85.553.628.73 1.435.73 2.31 0 .874-.287 1.704-.863 2.378a4.537 4.537 0 01-2.9 1.413c-1.571.134-3.143.247-4.736.247-1.595 0-3.166-.068-4.737-.247a4.532 4.532 0 01-2.9-1.413 3.616 3.616 0 01-.864-2.378c0-.875.178-1.682.73-2.31.754-.854 1.064-1.594 1.064-2.85V8.37c0-1.682.42-2.781 1.283-3.858C7.861 2.942 9.919 2 11.956 2h.09c2.08 0 4.204.987 5.466 2.625.82 1.054 1.195 2.108 1.195 3.745v.426zM9.074 20.061c0-.504.462-.734.89-.833.5-.106 3.545-.106 4.045 0 .428.099.89.33.89.833-.025.48-.306.904-.695 1.174a3.635 3.635 0 01-1.713.731 3.795 3.795 0 01-1.008 0 3.618 3.618 0 01-1.714-.732c-.39-.269-.67-.694-.695-1.173z"
fill="currentColor"
fillRule="evenodd"
/>
</svg>
);
};

export const CheckIcon = ({size, height, width, ...props}) => {
return (
<svg
fill="none"
height={size || height || 18}
viewBox="0 0 24 24"
width={size || width || 18}
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<path
d="M7.75 11.9999L10.58 14.8299L16.25 9.16992"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={1.5}
/>
</svg>
);
};

export default function App() {
return (
<div className="flex gap-5 items-center">
<Badge color="danger" content="5">
<Avatar radius="md" src="https://i.pravatar.cc/150?u=a042581f4e29026024d" />
</Badge>
<Badge color="success" content="" placement="bottom-right" shape="circle">
<Avatar radius="full" src="https://i.pravatar.cc/150?u=a04258a2462d826712d" />
</Badge>
<Badge color="danger" content="new" size="sm">
<Avatar
isBordered
color="danger"
radius="md"
src="https://i.pravatar.cc/300?u=a042581f4e29026709d"
/>
</Badge>
<Badge isOneChar color="success" content={<CheckIcon />} placement="bottom-right">
<Avatar
isBordered
color="success"
radius="md"
src="https://i.pravatar.cc/300?u=a042581f4e290267072"
/>
</Badge>
<Badge
isOneChar
color="danger"
content={<NotificationIcon size={12} />}
placement="top-right"
shape="circle"
>
<Avatar radius="full" size="lg" src="https://i.pravatar.cc/300?u=a042581f4e29026704f" />
</Badge>
</div>
);
}
105 changes: 1 addition & 104 deletions apps/docs/content/components/badge/content-examples.ts
Original file line number Diff line number Diff line change
@@ -1,110 +1,7 @@
export const NotificationIcon = `export const NotificationIcon = ({size, height, width, ...props}) => {
return (
<svg
fill="none"
height={size || height || 24}
viewBox="0 0 24 24"
width={size || width || 24}
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<path
clipRule="evenodd"
d="M18.707 8.796c0 1.256.332 1.997 1.063 2.85.553.628.73 1.435.73 2.31 0 .874-.287 1.704-.863 2.378a4.537 4.537 0 01-2.9 1.413c-1.571.134-3.143.247-4.736.247-1.595 0-3.166-.068-4.737-.247a4.532 4.532 0 01-2.9-1.413 3.616 3.616 0 01-.864-2.378c0-.875.178-1.682.73-2.31.754-.854 1.064-1.594 1.064-2.85V8.37c0-1.682.42-2.781 1.283-3.858C7.861 2.942 9.919 2 11.956 2h.09c2.08 0 4.204.987 5.466 2.625.82 1.054 1.195 2.108 1.195 3.745v.426zM9.074 20.061c0-.504.462-.734.89-.833.5-.106 3.545-.106 4.045 0 .428.099.89.33.89.833-.025.48-.306.904-.695 1.174a3.635 3.635 0 01-1.713.731 3.795 3.795 0 01-1.008 0 3.618 3.618 0 01-1.714-.732c-.39-.269-.67-.694-.695-1.173z"
fill='currentColor'
fillRule="evenodd"
/>
</svg>
);
};`;

export const CheckIcon = `export const CheckIcon = ({
size,
height,
width,
...props
}) => {
return (
<svg
width={size || width || 18}
height={size || height || 18}
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<path
d="M7.75 11.9999L10.58 14.8299L16.25 9.16992"
stroke="currentColor"
strokeWidth={1.5}
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
);
};`;

const App = `import {Badge, Avatar} from "@nextui-org/react";
import {NotificationIcon} from "./NotificationIcon";
import {CheckIcon} from "./CheckIcon";

export default function App() {
return (
<div className="flex gap-5 items-center">
<Badge content="5" color="danger">
<Avatar
radius="md"
src="https://i.pravatar.cc/150?u=a042581f4e29026024d"
/>
</Badge>
<Badge content="" color="success" shape="circle" placement="bottom-right">
<Avatar
radius="full"
src="https://i.pravatar.cc/150?u=a04258a2462d826712d"
/>
</Badge>
<Badge content="new" color="danger" size="sm">
<Avatar
isBordered
radius="md"
color="danger"
src="https://i.pravatar.cc/300?u=a042581f4e29026709d"
/>
</Badge>
<Badge
isOneChar
content={<CheckIcon />}
color="success"
placement="bottom-right"
>
<Avatar
isBordered
color="success"
radius="md"
src="https://i.pravatar.cc/300?u=a042581f4e290267072"
/>
</Badge>
<Badge
isOneChar
content={<NotificationIcon size={12} />}
color="danger"
shape="circle"
placement="top-right"
>
<Avatar
radius="full"
size="lg"
src="https://i.pravatar.cc/300?u=a042581f4e29026704f"
/>
</Badge>
</div>
);
}`;
import App from "./content-examples.raw.jsx?raw";

const react = {
"/App.jsx": App,
"/NotificationIcon.jsx": NotificationIcon,
"/CheckIcon.jsx": CheckIcon,
};

export default {
Expand Down
20 changes: 20 additions & 0 deletions apps/docs/content/components/badge/placements.raw.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {Badge, Avatar} from "@nextui-org/react";

export default function App() {
return (
<div className="flex gap-4 items-center">
<Badge color="danger" content="5" placement="top-right">
<Avatar isBordered radius="md" src="https://i.pravatar.cc/150?u=a042f81f4e29026024d" />
</Badge>
<Badge color="danger" content="5" placement="bottom-right">
<Avatar isBordered radius="md" src="https://i.pravatar.cc/150?u=a04258a2462d826712d" />
</Badge>
<Badge color="danger" content="5" placement="top-left">
<Avatar isBordered radius="md" src="https://i.pravatar.cc/150?u=a04258114e29026708c" />
</Badge>
<Badge color="danger" content="5" placement="bottom-left">
<Avatar isBordered radius="md" src="https://i.pravatar.cc/150?u=a04258114e29026302d" />
</Badge>
</div>
);
}
Loading