Skip to content

Commit

Permalink
feat(design): introduce some usefull components (#20)
Browse files Browse the repository at this point in the history
* feat(design): introduce some usefull components

* build: remove useless dep

* fix: code format

* fix

* fix code format
  • Loading branch information
AugustinMauroy authored Feb 26, 2024
1 parent e2a493d commit e767e4f
Show file tree
Hide file tree
Showing 32 changed files with 1,717 additions and 35 deletions.
11 changes: 7 additions & 4 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@ export default {
'@storybook/addon-interactions',
],
logLevel: 'error',
// enable when you have a public folder with assets
//staticDirs: ['../public'],
staticDirs: ['../public'],
typescript: { reactDocgen: false, check: false },
core: { disableTelemetry: true, disableWhatsNewNotifications: true },
framework: {
name: '@storybook/nextjs',
options: { builder: { useSWC: true } },
},
previewBody:
'<style>:root { color-scheme: light; } html[data-theme="dark"] { color-scheme: dark; }</style>' +
// Warning: this should be same as the one in `src/styles/globals.css`
'<body class="bg-gray-50 text-gray-950 dark:bg-gray-900 transition-colors dark:text-gray-50"></body>',
`<style>
:root { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
</style>
<body></body>`,

webpack: async config => ({
...config,
// Performance Hints do not make sense on Storybook as it is bloated by design
Expand Down
7 changes: 7 additions & 0 deletions .storybook/preview.ts → .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React from 'react';
import { withThemeByDataAttribute } from '@storybook/addon-themes';
import { ToastProvider } from '../providers/toast';
import type { Preview, ReactRenderer } from '@storybook/react';
import '../styles/globals.css';

Expand All @@ -19,6 +21,11 @@ const preview: Preview = {
defaultTheme: 'light',
attributeName: 'data-theme',
}),
Story => (
<ToastProvider viewportClassName="absolute top-0 left-0 list-none">
<Story />
</ToastProvider>
),
],
};

Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ The project is currently under development, so we only support this version(s) o
| 0.1.X | :white_check_mark: |

> \[!NOTE]\
>There is no compatibility yet with etherpad-lite
> There is no compatibility yet with etherpad-lite
4 changes: 3 additions & 1 deletion app/client/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import { useEffect } from 'react';
import io from 'socket.io-client';
const Page = () => {
import type { FC } from 'react';

const Page: FC = () => {
useEffect(() => {
const socket = io();
socket.on('connect', () => {
Expand Down
6 changes: 6 additions & 0 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Landing from '@/components/Sections/Landing';
import type { FC } from 'react';

const Page: FC = () => <Landing />;

export default Page;
23 changes: 23 additions & 0 deletions components/Common/Background/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.background {
@apply absolute
left-0
top-0
-z-10
size-full
bg-[url('/static/background.svg')]
bg-center
bg-no-repeat;

&::after {
@apply absolute
inset-0
m-auto
aspect-square
w-[300px]
rounded-full
bg-ether-400
blur-[120px]
content-['']
dark:bg-ether-700;
}
}
9 changes: 9 additions & 0 deletions components/Common/Background/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import BluredBackground from './';
import type { Meta as MetaObj, StoryObj } from '@storybook/react';

type Story = StoryObj<typeof BluredBackground>;
type Meta = MetaObj<typeof BluredBackground>;

export const Default: Story = {};

export default { component: BluredBackground } as Meta;
6 changes: 6 additions & 0 deletions components/Common/Background/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import styles from './index.module.css';
import type { FC } from 'react';

const BluredBackground: FC = () => <div className={styles.background} />;

export default BluredBackground;
4 changes: 2 additions & 2 deletions components/Common/Button/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HeartIcon } from '@heroicons/react/20/solid';
import { Heart } from 'lucide-react';
import Button from './';
import type { Meta as MetaObj, StoryObj } from '@storybook/react';

Expand All @@ -9,7 +9,7 @@ const defaultStory: Story = {
args: {
children: (
<>
<HeartIcon className="size-6" /> We love Etherpad
<Heart className="size-6" /> We love Etherpad
</>
),
// it's allow to have button on the storybook layout to toggle the disabled state
Expand Down
1 change: 1 addition & 0 deletions components/Common/Input/index.module.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.inputWrapper {
@apply flex
w-full
flex-col
gap-1.5;

Expand Down
4 changes: 2 additions & 2 deletions components/Common/Select/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';
import * as Primitive from '@radix-ui/react-select';
import { ChevronDownIcon } from '@heroicons/react/24/outline';
import { ChevronDown } from 'lucide-react';
import { useId, useMemo } from 'react';
import classNames from 'classnames';
import styles from './index.module.css';
Expand Down Expand Up @@ -70,7 +70,7 @@ const Select: FC<SelectProps> = ({
id={id}
>
<Primitive.Value placeholder={placeholder} />
<ChevronDownIcon className={styles.icon} />
<ChevronDown className={styles.icon} />
</Primitive.Trigger>
<Primitive.Portal>
<Primitive.Content
Expand Down
60 changes: 60 additions & 0 deletions components/Common/Toast/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.root {
@apply m-6
w-fit
max-w-80
rounded
border
border-gray-200
px-4
py-3
shadow-lg
dark:border-gray-800;

.message {
@apply inline-flex
items-center
justify-center
gap-2
font-medium;

svg {
@apply size-5;
}
}
}

.success {
@apply border-green-200
bg-green-100
text-green-800
dark:border-green-600
dark:bg-green-800
dark:text-white;
}

.error {
@apply border-red-200
bg-red-100
text-red-800
dark:border-red-600
dark:bg-red-800
dark:text-white;
}

.warning {
@apply border-yellow-200
bg-yellow-100
text-yellow-800
dark:border-yellow-600
dark:bg-yellow-800
dark:text-white;
}

.info {
@apply border-ether-200
bg-ether-100
text-ether-800
dark:border-ether-600
dark:bg-ether-800
dark:text-white;
}
59 changes: 59 additions & 0 deletions components/Common/Toast/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { BellDotIcon } from 'lucide-react';
import Notification from '.';
import type { Meta as MetaObj, StoryObj } from '@storybook/react';

type Story = StoryObj<typeof Notification>;
type Meta = MetaObj<typeof Notification>;

export const Default: Story = {
args: {
open: true,
duration: 5000,
children: 'OK, everything is fine!',
},
};

export const TimedNotification: Story = {
args: {
duration: 5000,
children: 'OK, everything is fine!',
},
};

export const WithJSX: Story = {
args: {
open: true,
children: (
<>
<BellDotIcon />
OK, everything is fine!
</>
),
},
};

export const Success: Story = {
args: {
open: true,
variant: 'success',
children: 'OK, everything is fine!',
},
};

export const Error: Story = {
args: {
open: true,
variant: 'error',
children: 'Something went wrong!',
},
};

export const Warning: Story = {
args: {
open: true,
variant: 'warning',
children: 'Be careful!',
},
};

export default { component: Notification } as Meta;
35 changes: 35 additions & 0 deletions components/Common/Toast/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as ToastPrimitive from '@radix-ui/react-toast';
import classNames from 'classnames';
import styles from './index.module.css';
import type { FC, PropsWithChildren } from 'react';

type ToastProps = PropsWithChildren<{
variant?: 'success' | 'error' | 'warning' | 'info';
open?: boolean;
duration?: number;
onChange?: (value: boolean) => void;
className?: string;
}>;

const Toast: FC<ToastProps> = ({
variant = 'info',
open,
// 2s duration
duration = 2000,
onChange,
children,
className,
}) => (
<ToastPrimitive.Root
open={open}
duration={duration}
onOpenChange={onChange}
className={classNames(styles.root, styles[variant], className)}
>
<ToastPrimitive.Title className={styles.message}>
{children}
</ToastPrimitive.Title>
</ToastPrimitive.Root>
);

export default Toast;
23 changes: 23 additions & 0 deletions components/Logo/Platform/Apple.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { FC, SVGProps } from 'react';

const Apple: FC<SVGProps<SVGSVGElement>> = props => (
<svg
width="32"
height="32"
viewBox="0 0 32 32"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<path
d="M30 16c0 7.728-6.265 14-14 14S2 23.728 2 16C2 8.265 8.265 2 16 2s14 6.265 14 14Z"
fill="#283544"
/>
<path
d="M22.562 12.457c-.076.045-1.895.986-1.895 3.07.086 2.38 2.295 3.213 2.333 3.213-.038.045-.334 1.136-1.21 2.28-.694.986-1.466 1.98-2.637 1.98-1.114 0-1.514-.657-2.8-.657-1.381 0-1.772.657-2.829.657-1.171 0-2-1.047-2.733-2.023-.952-1.278-1.761-3.284-1.79-5.21-.02-1.02.19-2.023.724-2.875.752-1.19 2.095-1.997 3.561-2.023 1.124-.036 2.124.719 2.81.719.657 0 1.885-.72 3.275-.72.6.001 2.2.17 3.191 1.59Zm-6.561-1.792c-.2-.932.352-1.864.866-2.458.657-.72 1.695-1.207 2.59-1.207a3.334 3.334 0 0 1-.952 2.511c-.58.72-1.58 1.26-2.504 1.154Z"
fill="#fff"
/>
</svg>
);

export default Apple;
22 changes: 22 additions & 0 deletions components/Logo/Platform/Generic.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { FC, SVGProps } from 'react';

const Generic: FC<SVGProps<SVGSVGElement>> = props => (
<svg
width="32"
height="32"
viewBox="0 0 32 32"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<path
d="M16 29.333c7.364 0 13.333-5.97 13.333-13.333 0-7.364-5.97-13.334-13.333-13.334C8.636 2.666 2.667 8.636 2.667 16S8.637 29.333 16 29.333Z"
stroke="#000"
strokeWidth="2.667"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
);

export default Generic;
Loading

0 comments on commit e767e4f

Please sign in to comment.