File size: 18,622 Bytes
19e25f3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 |
// !STARTERCONF You can delete this page
import clsx from 'clsx';
import * as React from 'react';
import {
HiArrowRight,
HiOutlineCreditCard,
HiOutlineDesktopComputer,
HiOutlineDeviceMobile,
HiOutlineShieldCheck,
HiPlus,
} from 'react-icons/hi';
import Button from '@/components/buttons/Button';
import IconButton from '@/components/buttons/IconButton';
import TextButton from '@/components/buttons/TextButton';
import Layout from '@/components/layout/Layout';
import ArrowLink from '@/components/links/ArrowLink';
import ButtonLink from '@/components/links/ButtonLink';
import PrimaryLink from '@/components/links/PrimaryLink';
import UnderlineLink from '@/components/links/UnderlineLink';
import UnstyledLink from '@/components/links/UnstyledLink';
import NextImage from '@/components/NextImage';
import Seo from '@/components/Seo';
import Skeleton from '@/components/Skeleton';
type Color = (typeof colorList)[number];
export default function ComponentsPage() {
const [mode, setMode] = React.useState<'dark' | 'light'>('light');
const [color, setColor] = React.useState<Color>('sky');
function toggleMode() {
return mode === 'dark' ? setMode('light') : setMode('dark');
}
const textColor = mode === 'dark' ? 'text-gray-300' : 'text-gray-600';
return (
<Layout>
<Seo
templateTitle='Components'
description='Pre-built components with awesome default'
/>
<main>
<section
className={clsx(mode === 'dark' ? 'bg-dark' : 'bg-white', color)}
>
<div
className={clsx(
'layout min-h-screen py-20',
mode === 'dark' ? 'text-white' : 'text-black'
)}
>
<h1>Built-in Components</h1>
<ArrowLink direction='left' className='mt-2' href='/'>
Back to Home
</ArrowLink>
<div className='mt-8 flex flex-wrap gap-2'>
<Button
onClick={toggleMode}
variant={mode === 'dark' ? 'light' : 'dark'}
>
Set to {mode === 'dark' ? 'light' : 'dark'}
</Button>
{/* <Button onClick={randomize}>Randomize CSS Variable</Button> */}
</div>
<ol className='mt-8 space-y-6'>
<li className='space-y-2'>
<h2 className='text-lg md:text-xl'>Customize Colors</h2>
<p className={clsx('!mt-1 text-sm', textColor)}>
You can change primary color to any Tailwind CSS colors. See
globals.css to change your color.
</p>
<div className='flex flex-wrap gap-2'>
<select
name='color'
id='color'
value={color}
className={clsx(
'block max-w-xs rounded',
mode === 'dark'
? 'bg-dark border border-gray-600'
: 'border-gray-300 bg-white',
'focus:border-primary-400 focus:ring-primary-400 focus:outline-none focus:ring'
)}
onChange={(e) => setColor(e.target.value as Color)}
>
{colorList.map((c) => (
<option key={c} value={c}>
{c}
</option>
))}
</select>
<ButtonLink href='https://github.com/theodorusclarence/ts-nextjs-tailwind-starter/blob/main/src/styles/colors.css'>
Check list of colors
</ButtonLink>
</div>
<div className='flex flex-wrap gap-2 text-xs font-medium'>
<div className='bg-primary-50 flex h-10 w-10 items-center justify-center rounded text-black'>
50
</div>
<div className='bg-primary-100 flex h-10 w-10 items-center justify-center rounded text-black'>
100
</div>
<div className='bg-primary-200 flex h-10 w-10 items-center justify-center rounded text-black'>
200
</div>
<div className='bg-primary-300 flex h-10 w-10 items-center justify-center rounded text-black'>
300
</div>
<div className='bg-primary-400 flex h-10 w-10 items-center justify-center rounded text-black'>
400
</div>
<div className='bg-primary-500 flex h-10 w-10 items-center justify-center rounded text-black'>
500
</div>
<div className='bg-primary-600 flex h-10 w-10 items-center justify-center rounded text-white'>
600
</div>
<div className='bg-primary-700 flex h-10 w-10 items-center justify-center rounded text-white'>
700
</div>
<div className='bg-primary-800 flex h-10 w-10 items-center justify-center rounded text-white'>
800
</div>
<div className='bg-primary-900 flex h-10 w-10 items-center justify-center rounded text-white'>
900
</div>
<div className='bg-primary-950 flex h-10 w-10 items-center justify-center rounded text-white'>
950
</div>
</div>
</li>
<li className='space-y-2'>
<h2 className='text-lg md:text-xl'>UnstyledLink</h2>
<p className={clsx('!mt-1 text-sm', textColor)}>
No style applied, differentiate internal and outside links,
give custom cursor for outside links.
</p>
<div className='space-x-2'>
<UnstyledLink href='/'>Internal Links</UnstyledLink>
<UnstyledLink href='https://theodorusclarence.com'>
Outside Links
</UnstyledLink>
</div>
</li>
<li className='space-y-2'>
<h2 className='text-lg md:text-xl'>PrimaryLink</h2>
<p className={clsx('!mt-1 text-sm', textColor)}>
Add styling on top of UnstyledLink, giving a primary color to
the link.
</p>
<div className='space-x-2'>
<PrimaryLink href='/'>Internal Links</PrimaryLink>
<PrimaryLink href='https://theodorusclarence.com'>
Outside Links
</PrimaryLink>
</div>
</li>
<li className='space-y-2'>
<h2 className='text-lg md:text-xl'>UnderlineLink</h2>
<p className={clsx('!mt-1 text-sm', textColor)}>
Add styling on top of UnstyledLink, giving a dotted and
animated underline.
</p>
<div className='space-x-2'>
<UnderlineLink href='/'>Internal Links</UnderlineLink>
<UnderlineLink href='https://theodorusclarence.com'>
Outside Links
</UnderlineLink>
</div>
</li>
<li className='space-y-2'>
<h2 className='text-lg md:text-xl'>ArrowLink</h2>
<p className={clsx('!mt-1 text-sm', textColor)}>
Useful for indicating navigation, I use this quite a lot, so
why not build a component with some whimsy touch?
</p>
<div className='flex flex-wrap items-center gap-4'>
<ArrowLink href='/' direction='left'>
Direction Left
</ArrowLink>
<ArrowLink href='/'>Direction Right</ArrowLink>
<ArrowLink
as={UnstyledLink}
className='inline-flex items-center'
href='/'
>
Polymorphic
</ArrowLink>
<ArrowLink
as={ButtonLink}
variant='light'
className='inline-flex items-center'
href='/'
>
Polymorphic
</ArrowLink>
</div>
</li>
<li className='space-y-2'>
<h2 className='text-lg md:text-xl'>ButtonLink</h2>
<p className={clsx('!mt-1 text-sm', textColor)}>
Button styled link with 3 variants.
</p>
<div className='flex flex-wrap gap-2'>
<ButtonLink
variant='primary'
href='https://theodorusclarence.com'
>
Primary Variant
</ButtonLink>
<ButtonLink
variant='outline'
isDarkBg={mode === 'dark'}
href='https://theodorusclarence.com'
>
Outline Variant
</ButtonLink>
<ButtonLink
variant='ghost'
isDarkBg={mode === 'dark'}
href='https://theodorusclarence.com'
>
Ghost Variant
</ButtonLink>
<ButtonLink
variant='dark'
href='https://theodorusclarence.com'
>
Dark Variant
</ButtonLink>
<ButtonLink
variant='light'
href='https://theodorusclarence.com'
>
Light Variant
</ButtonLink>
</div>
</li>
<li className='space-y-2'>
<h2 className='text-lg md:text-xl'>Button</h2>
<p className={clsx('!mt-1 text-sm', textColor)}>
Ordinary button with style.
</p>
<div className='flex flex-wrap gap-2'>
<Button variant='primary'>Primary Variant</Button>
<Button variant='outline' isDarkBg={mode === 'dark'}>
Outline Variant
</Button>
<Button variant='ghost' isDarkBg={mode === 'dark'}>
Ghost Variant
</Button>
<Button variant='dark'>Dark Variant</Button>
<Button variant='light'>Light Variant</Button>
</div>
<div className='flex flex-wrap gap-2'>
<Button
variant='primary'
leftIcon={HiPlus}
rightIcon={HiArrowRight}
>
Icon
</Button>
<Button
variant='outline'
leftIcon={HiPlus}
rightIcon={HiArrowRight}
isDarkBg={mode === 'dark'}
>
Icon
</Button>
<Button
variant='ghost'
leftIcon={HiPlus}
rightIcon={HiArrowRight}
isDarkBg={mode === 'dark'}
>
Icon
</Button>
<Button
variant='dark'
leftIcon={HiPlus}
rightIcon={HiArrowRight}
>
Icon
</Button>
<Button
variant='light'
leftIcon={HiPlus}
rightIcon={HiArrowRight}
>
Icon
</Button>
</div>
<div className='!mt-4 flex flex-wrap gap-2'>
<Button size='sm' variant='primary'>
Small Size
</Button>
<Button
size='sm'
variant='outline'
isDarkBg={mode === 'dark'}
>
Small Size
</Button>
<Button size='sm' variant='ghost' isDarkBg={mode === 'dark'}>
Small Size
</Button>
<Button size='sm' variant='dark'>
Small Size
</Button>
<Button size='sm' variant='light'>
Small Size
</Button>
</div>
<div className='flex flex-wrap gap-2'>
<Button
size='sm'
variant='primary'
leftIcon={HiPlus}
rightIcon={HiArrowRight}
>
Icon
</Button>
<Button
size='sm'
variant='outline'
leftIcon={HiPlus}
rightIcon={HiArrowRight}
isDarkBg={mode === 'dark'}
>
Icon
</Button>
<Button
size='sm'
variant='ghost'
leftIcon={HiPlus}
rightIcon={HiArrowRight}
isDarkBg={mode === 'dark'}
>
Icon
</Button>
<Button
size='sm'
variant='dark'
leftIcon={HiPlus}
rightIcon={HiArrowRight}
>
Icon
</Button>
<Button
size='sm'
variant='light'
leftIcon={HiPlus}
rightIcon={HiArrowRight}
>
Icon
</Button>
</div>
<div className='!mt-4 flex flex-wrap gap-2'>
<Button disabled variant='primary'>
Disabled
</Button>
<Button disabled variant='outline' isDarkBg={mode === 'dark'}>
Disabled
</Button>
<Button disabled variant='ghost' isDarkBg={mode === 'dark'}>
Disabled
</Button>
<Button disabled variant='dark'>
Disabled
</Button>
<Button disabled variant='light'>
Disabled
</Button>
</div>
<div className='flex flex-wrap gap-2'>
<Button isLoading variant='primary'>
Disabled
</Button>
<Button
isLoading
variant='outline'
isDarkBg={mode === 'dark'}
>
Disabled
</Button>
<Button isLoading variant='ghost' isDarkBg={mode === 'dark'}>
Disabled
</Button>
<Button isLoading variant='dark'>
Disabled
</Button>
<Button isLoading variant='light'>
Disabled
</Button>
</div>
</li>
<li className='space-y-2'>
<h2 className='text-lg md:text-xl'>TextButton</h2>
<p className={clsx('!mt-1 text-sm', textColor)}>
Button with a text style
</p>
<div className='space-x-2'>
<TextButton>Primary Variant</TextButton>
<TextButton variant='basic'>Basic Variant</TextButton>
</div>
</li>
<li className='space-y-2'>
<h2 className='text-lg md:text-xl'>IconButton</h2>
<p className={clsx('!mt-1 text-sm', textColor)}>
Button with only icon inside
</p>
<div className='space-x-2'>
<IconButton icon={HiPlus} />
<IconButton
variant='outline'
icon={HiOutlineDesktopComputer}
/>
<IconButton variant='ghost' icon={HiOutlineDeviceMobile} />
<IconButton variant='dark' icon={HiOutlineShieldCheck} />
<IconButton variant='light' icon={HiOutlineCreditCard} />
</div>
</li>
<li className='space-y-2'>
<h2 className='text-lg md:text-xl'>Custom 404 Page</h2>
<p className={clsx('!mt-1 text-sm', textColor)}>
Styled 404 page with some animation.
</p>
<div className='flex flex-wrap gap-2'>
<ButtonLink href='/404'>Visit the 404 page</ButtonLink>
</div>
</li>
<li className='space-y-2'>
<h2 className='text-lg md:text-xl'>Next Image</h2>
<p className={clsx('!mt-1 text-sm', textColor)}>
Next Image with default props and skeleton animation
</p>
<NextImage
useSkeleton
className='w-32 md:w-40'
src='/favicon/android-chrome-192x192.png'
width='180'
height='180'
alt='Icon'
/>
</li>
<li className='space-y-2'>
<h2 className='text-lg md:text-xl'>Skeleton</h2>
<p className={clsx('!mt-1 text-sm', textColor)}>
Skeleton with shimmer effect
</p>
<Skeleton className='h-72 w-72' />
</li>
</ol>
</div>
</section>
</main>
</Layout>
);
}
const colorList = [
'slate',
'gray',
'zinc',
'neutral',
'stone',
'red',
'orange',
'amber',
'yellow',
'lime',
'green',
'emerald',
'teal',
'cyan',
'sky',
'blue',
'indigo',
'violet',
'purple',
'fuchsia',
'pink',
'rose',
] as const;
|