First pass at creating a new website

Signed-off-by: Charles de Dreuille <charles.dedreuille@gmail.com>
This commit is contained in:
Charles de Dreuille
2024-12-29 16:05:51 +01:00
parent a51536e546
commit aaf1c3b4d2
24 changed files with 3992 additions and 107 deletions
+41
View File
@@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
# env files (can opt-in for committing if needed)
.env*
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts
+36
View File
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
## Getting Started
First, run the development server:
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
## Learn More
To learn more about Next.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
## Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

+11
View File
@@ -0,0 +1,11 @@
body {
display: flex;
flex-direction: row;
background-color: var(--canon-background);
color: var(--canon-text-primary);
}
iframe {
border: none;
width: 100%;
}
+30
View File
@@ -0,0 +1,30 @@
import type { Metadata } from 'next';
import { Sidebar } from '../components/sidebar';
import '../../src/css/core.css';
import '../../src/css/components.css';
import './globals.css';
import { CanonProvider } from '../../src/contexts/canon';
export const metadata: Metadata = {
title: 'Canon',
description: 'UI library for Backstage',
};
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en" data-theme="light">
<body>
<CanonProvider>
<>
<Sidebar />
{children}
</>
</CanonProvider>
</body>
</html>
);
}
@@ -0,0 +1,3 @@
.page {
flex: 1;
}
+18
View File
@@ -0,0 +1,18 @@
'use client';
import { useSearchParams } from 'next/navigation';
import styles from './page.module.css';
export default function Home() {
const searchParams = useSearchParams();
const theme = searchParams.get('theme') === 'dark' ? 'Dark' : 'Light';
const chromaticId = '67584b7e8c2eb09c0422c27e-dmfbzicnkw';
const chromaticUrl = `https://${chromaticId}.chromatic.com/iframe.html`;
const iframeUrl = `${chromaticUrl}?globals=theme%3A${theme}&args=&id=components-button--primary`;
return (
<div className={styles.page}>
<iframe src={iframeUrl} id="canon-iframe" />
</div>
);
}
@@ -0,0 +1,3 @@
export default function PlaygroundPage() {
return <div>Playground</div>;
}
@@ -0,0 +1,72 @@
.tabs {
border-radius: 0.375rem;
flex: 1;
width: 100%;
background-color: var(--canon-surface-2);
}
.list {
display: flex;
position: relative;
z-index: 0;
padding-inline: 0.25rem;
gap: 0.25rem;
}
.tab {
display: flex;
align-items: center;
justify-content: center;
border: 0;
margin: 0;
outline: 0;
background: none;
appearance: none;
color: var(--canon-text-secondary);
font-family: inherit;
font-size: 0.75rem;
line-height: 1.25rem;
font-weight: 500;
user-select: none;
height: 2.25rem;
flex: 1;
cursor: pointer;
&[data-selected] {
color: var(--canon-text-primary);
}
@media (hover: hover) {
&:hover {
color: var(--canon-text-primary);
}
}
&:focus-visible {
position: relative;
&::before {
content: '';
position: absolute;
inset: 0.25rem 0;
border-radius: 0.25rem;
outline: 2px solid var(--canon-surface-1);
outline-offset: -1px;
}
}
}
.indicator {
position: absolute;
z-index: -1;
left: 0;
top: 50%;
translate: var(--active-tab-left) -50%;
width: var(--active-tab-width);
height: 1.8rem;
border-radius: 0.25rem;
background-color: var(--canon-surface-1);
transition-property: translate, width;
transition-duration: 200ms;
transition-timing-function: ease-in-out;
}
@@ -0,0 +1,84 @@
'use client';
import styles from './Tabs.module.css';
import { Tabs } from '@base-ui-components/react/tabs';
import { Icon } from '../../../src/components/Icon';
import { usePathname, useSearchParams } from 'next/navigation';
import { useRouter } from 'next/navigation';
export const TabsVersion = () => {
return (
<Tabs.Root className={styles.tabs} defaultValue="v1">
<Tabs.List className={styles.list}>
<Tabs.Tab className={styles.tab} value="v1">
V1
</Tabs.Tab>
<Tabs.Tab className={styles.tab} value="v2">
V2
</Tabs.Tab>
<Tabs.Indicator className={styles.indicator} />
</Tabs.List>
</Tabs.Root>
);
};
export const TabsTheme = () => {
const searchParams = useSearchParams();
const theme = searchParams.get('theme') === 'dark' ? 'dark' : 'light';
const current = new URLSearchParams(Array.from(searchParams.entries()));
const router = useRouter();
const onValueChange = (value: string) => {
current.set('theme', value);
router.push(`/?${current.toString()}`);
};
return (
<Tabs.Root
className={styles.tabs}
value={theme}
onValueChange={onValueChange}
>
<Tabs.List className={styles.list}>
<Tabs.Tab className={styles.tab} value="light">
<Icon name="sun" />
</Tabs.Tab>
<Tabs.Tab className={styles.tab} value="dark">
<Icon name="moon" />
</Tabs.Tab>
<Tabs.Indicator className={styles.indicator} />
</Tabs.List>
</Tabs.Root>
);
};
export const TabsPages = () => {
const pathname = usePathname();
const router = useRouter();
const onValueChange = (value: string) => {
if (value === 'docs') {
router.push('/');
} else {
router.push('/playground');
}
};
return (
<Tabs.Root
className={styles.tabs}
value={pathname.includes('playground') ? 'playground' : 'docs'}
onValueChange={onValueChange}
>
<Tabs.List className={styles.list}>
<Tabs.Tab className={styles.tab} value="docs">
Documentation
</Tabs.Tab>
<Tabs.Tab className={styles.tab} value="playground">
Playground
</Tabs.Tab>
<Tabs.Indicator className={styles.indicator} />
</Tabs.List>
</Tabs.Root>
);
};
@@ -0,0 +1,46 @@
.sidebar {
width: 280px;
height: 100vh;
color: var(--canon-text-primary);
background-color: var(--canon-surface-1);
border-right: 1px solid var(--canon-border-base);
padding-left: 20px;
padding-right: 20px;
}
.content {
padding-top: 20px;
}
.actions {
display: flex;
flex-direction: row;
gap: 12px;
margin-top: 20px;
margin-bottom: 12px;
}
.menu {
margin-top: 48px;
}
.title {
font-size: 0.875rem;
font-weight: 500;
margin-bottom: 12px;
margin-top: 32px;
}
.menu a {
display: block;
font-size: 0.875rem;
font-weight: 400;
line-height: 1.25rem;
color: var(--canon-text-secondary);
text-decoration: none;
height: 1.75rem;
&:hover {
color: var(--canon-text-primary);
}
}
@@ -0,0 +1,32 @@
import styles from './Sidebar.module.css';
import Image from 'next/image';
import { TabsVersion, TabsTheme, TabsPages } from '../Tabs';
import { Grid } from '../../../src/components/Grid';
import Link from 'next/link';
export const Sidebar = () => {
return (
<div className={styles.sidebar}>
<div className={styles.content}>
<Image src="/logo.svg" alt="Canon" width={89} height={27} priority />
<div className={styles.actions}>
<TabsVersion />
<TabsTheme />
</div>
<TabsPages />
<div className={styles.menu}>
<h2 className={styles.title}>Core Concepts</h2>
<Link href="/docs/core-concepts/introduction">Iconography</Link>
<Link href="/docs/core-concepts/components">Layout</Link>
<Link href="/docs/core-concepts/accessibility">Responsive</Link>
<Link href="/docs/core-concepts/theming">Theming</Link>
<h2 className={styles.title}>Components</h2>
<Link href="/docs/components/button">Button</Link>
<Link href="/docs/components/card">Card</Link>
<Link href="/docs/components/input">Input</Link>
<Link href="/docs/components/select">Select</Link>
</div>
</div>
</div>
);
};
@@ -0,0 +1,16 @@
import { dirname } from "path";
import { fileURLToPath } from "url";
import { FlatCompat } from "@eslint/eslintrc";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
});
const eslintConfig = [
...compat.extends("next/core-web-vitals", "next/typescript"),
];
export default eslintConfig;
+7
View File
@@ -0,0 +1,7 @@
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
/* config options here */
};
export default nextConfig;
+26
View File
@@ -0,0 +1,26 @@
{
"name": "canon-docs",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@base-ui-components/react": "^1.0.0-alpha.4",
"next": "15.1.3",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
"@eslint/eslintrc": "^3",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "15.1.3",
"typescript": "^5"
}
}
@@ -0,0 +1 @@
<svg width="89" height="27" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M77.414 9.71h3.036v2.992l-.264-.022c.279-.88.748-1.65 1.408-2.31.675-.66 1.533-.99 2.574-.99 1.086 0 1.9.352 2.442 1.056.558.689.836 1.598.836 2.728v7.502H84.41v-6.6c0-.66-.117-1.159-.352-1.496-.234-.338-.623-.506-1.166-.506-.601 0-1.122.271-1.562.814a4.321 4.321 0 0 0-.88 1.848v5.94h-3.036V9.71ZM69.868 21.04c-1.13 0-2.142-.257-3.036-.77a5.547 5.547 0 0 1-2.068-2.09c-.484-.895-.726-1.892-.726-2.992 0-1.115.242-2.112.726-2.992a5.503 5.503 0 0 1 2.068-2.112c.88-.514 1.892-.77 3.036-.77 1.144 0 2.156.256 3.036.77a5.347 5.347 0 0 1 2.046 2.112c.498.88.748 1.87.748 2.97 0 1.114-.25 2.12-.748 3.014a5.343 5.343 0 0 1-2.068 2.09c-.88.513-1.885.77-3.014.77Zm0-2.618c.557 0 1.048-.132 1.474-.396a2.79 2.79 0 0 0 .99-1.144c.234-.499.352-1.064.352-1.694 0-.63-.118-1.188-.352-1.672a2.764 2.764 0 0 0-.99-1.166c-.426-.279-.917-.418-1.474-.418-.558 0-1.05.14-1.474.418a2.764 2.764 0 0 0-.99 1.166c-.22.484-.33 1.041-.33 1.672 0 .63.11 1.195.33 1.694.234.484.564.865.99 1.144.425.264.916.396 1.474.396ZM52.385 9.71h3.036v2.992l-.264-.022c.279-.88.748-1.65 1.408-2.31.675-.66 1.533-.99 2.574-.99 1.085 0 1.9.352 2.442 1.056.557.689.836 1.598.836 2.728v7.502h-3.036v-6.6c0-.66-.117-1.159-.352-1.496-.235-.338-.623-.506-1.166-.506-.601 0-1.122.271-1.562.814a4.321 4.321 0 0 0-.88 1.848v5.94h-3.036V9.71ZM43.904 20.952c-1.026 0-1.87-.308-2.53-.924-.66-.616-.99-1.416-.99-2.398 0-1.115.418-2.01 1.254-2.684.85-.69 2.105-1.034 3.762-1.034h2.75l-.924.352v-.462c0-.572-.176-1.02-.528-1.342-.352-.338-.931-.506-1.738-.506-.69 0-1.386.154-2.09.462-.704.308-1.29.69-1.76 1.144v-2.882c.47-.352 1.1-.66 1.892-.924a7.942 7.942 0 0 1 2.486-.396c1.599 0 2.78.41 3.542 1.232.778.806 1.166 1.914 1.166 3.322v5.742c0 .176.008.352.022.528.03.161.066.322.11.484h-3.014v-3.3l.044 1.386a4.044 4.044 0 0 1-1.32 1.606c-.572.396-1.283.594-2.134.594Zm.858-2.156c.558 0 1.049-.206 1.474-.616.44-.426.77-.954.99-1.584v-.792h-1.562c-.762 0-1.334.146-1.716.44-.381.278-.572.674-.572 1.188 0 .41.125.74.374.99.264.25.602.374 1.012.374ZM34.66 21.04c-1.525 0-2.874-.345-4.047-1.034-1.174-.704-2.09-1.68-2.75-2.926-.646-1.247-.968-2.662-.968-4.246 0-1.584.322-2.992.968-4.224.66-1.232 1.576-2.193 2.75-2.882 1.173-.704 2.522-1.056 4.048-1.056.968 0 1.818.11 2.552.33.748.22 1.356.506 1.826.858v3.498c-.396-.484-.96-.895-1.694-1.232-.719-.338-1.51-.506-2.376-.506-.939 0-1.775.22-2.508.66-.719.44-1.284 1.056-1.694 1.848-.396.792-.594 1.694-.594 2.706 0 1.026.198 1.943.594 2.75.41.792.975 1.408 1.694 1.848.733.44 1.57.66 2.508.66.88 0 1.68-.162 2.398-.484.718-.323 1.276-.726 1.672-1.21v3.41a5.686 5.686 0 0 1-1.87.902c-.704.22-1.54.33-2.508.33ZM11.275 6.271c.276.526.019 1.152-.464 1.498a5.846 5.846 0 0 0 1.004 10.082c.454.205.789.632.789 1.13v6.206a.837.837 0 0 1-.838.837C5.33 26.024.112 20.804.112 14.366V.862C.112.399.487.024.95.024c4.483 0 8.376 2.533 10.325 6.247Z" fill="#000"/><path d="M14.037 16.729a4.237 4.237 0 0 0 4.234-4.24 4.237 4.237 0 0 0-4.234-4.242 4.237 4.237 0 0 0-4.234 4.241 4.237 4.237 0 0 0 4.234 4.24Z" fill="#000"/></svg>

After

Width:  |  Height:  |  Size: 3.0 KiB

+27
View File
@@ -0,0 +1,27 @@
{
"compilerOptions": {
"target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
File diff suppressed because it is too large Load Diff
@@ -14,6 +14,8 @@
* limitations under the License.
*/
'use client';
import React from 'react';
import { useCanon } from '../../contexts/canon';
import type { IconProps } from './types';
@@ -35,6 +35,8 @@ import {
RiArrowRightCircleLine,
RiArrowUpCircleLine,
RiCheckLine,
RiMoonLine,
RiSunLine,
} from '@remixicon/react';
// List of default icons
@@ -54,6 +56,8 @@ export const defaultIcons: IconMap = {
chevronRight: RiArrowRightSLine,
cloud: RiCloudFill,
heart: RiHeartFill,
moon: RiMoonLine,
plus: RiAddLine,
sun: RiSunLine,
trash: RiDeleteBin6Line,
};
@@ -31,7 +31,9 @@ export type IconNames =
| 'chevronUp'
| 'cloud'
| 'heart'
| 'moon'
| 'plus'
| 'sun'
| 'trash';
/** @public */
+2
View File
@@ -14,6 +14,8 @@
* limitations under the License.
*/
'use client';
import React, { createContext, useContext, ReactNode } from 'react';
import { IconMap, IconNames } from '../components/Icon/types';
import { defaultIcons } from '../components/Icon/icons';
+2 -2
View File
@@ -14,9 +14,9 @@
* limitations under the License.
*/
@layer base {
@import './normalize.css';
@import './normalize.css';
@layer base {
*,
html,
body {
+107 -105
View File
@@ -9,193 +9,195 @@ Document
Use a better box model (opinionated).
*/
*,
::before,
::after {
box-sizing: border-box;
}
@layer base {
*,
::before,
::after {
box-sizing: border-box;
}
html {
/* Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3) */
font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif,
'Apple Color Emoji', 'Segoe UI Emoji';
line-height: 1.15; /* 1. Correct the line height in all browsers. */
-webkit-text-size-adjust: 100%; /* 2. Prevent adjustments of font size after orientation changes in iOS. */
tab-size: 4; /* 3. Use a more readable tab size (opinionated). */
}
html {
/* Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3) */
font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif,
'Apple Color Emoji', 'Segoe UI Emoji';
line-height: 1.15; /* 1. Correct the line height in all browsers. */
-webkit-text-size-adjust: 100%; /* 2. Prevent adjustments of font size after orientation changes in iOS. */
tab-size: 4; /* 3. Use a more readable tab size (opinionated). */
}
/*
/*
Sections
========
*/
body {
margin: 0; /* Remove the margin in all browsers. */
}
body {
margin: 0; /* Remove the margin in all browsers. */
}
/*
/*
Text-level semantics
====================
*/
/**
/**
Add the correct font weight in Chrome and Safari.
*/
b,
strong {
font-weight: bolder;
}
b,
strong {
font-weight: bolder;
}
/**
/**
1. Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3)
2. Correct the odd 'em' font sizing in all browsers.
*/
code,
kbd,
samp,
pre {
font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo,
monospace; /* 1 */
font-size: 1em; /* 2 */
}
code,
kbd,
samp,
pre {
font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono',
Menlo, monospace; /* 1 */
font-size: 1em; /* 2 */
}
/**
/**
Add the correct font size in all browsers.
*/
small {
font-size: 80%;
}
small {
font-size: 80%;
}
/**
/**
Prevent 'sub' and 'sup' elements from affecting the line height in all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
sup {
top: -0.5em;
}
/*
/*
Tabular data
============
*/
/**
/**
Correct table border color inheritance in Chrome and Safari. (https://issues.chromium.org/issues/40615503, https://bugs.webkit.org/show_bug.cgi?id=195016)
*/
table {
border-color: currentcolor;
}
table {
border-color: currentcolor;
}
/*
/*
Forms
=====
*/
/**
/**
1. Change the font styles in all browsers.
2. Remove the margin in Firefox and Safari.
*/
button,
input,
optgroup,
select,
textarea {
font-family: inherit; /* 1 */
font-size: 100%; /* 1 */
line-height: 1.15; /* 1 */
margin: 0; /* 2 */
}
button,
input,
optgroup,
select,
textarea {
font-family: inherit; /* 1 */
font-size: 100%; /* 1 */
line-height: 1.15; /* 1 */
margin: 0; /* 2 */
}
/**
/**
Correct the inability to style clickable types in iOS and Safari.
*/
button,
[type='button'],
[type='reset'],
[type='submit'] {
-webkit-appearance: button;
}
button,
[type='button'],
[type='reset'],
[type='submit'] {
-webkit-appearance: button;
}
/**
/**
Remove the padding so developers are not caught out when they zero out 'fieldset' elements in all browsers.
*/
legend {
padding: 0;
}
legend {
padding: 0;
}
/**
/**
Add the correct vertical alignment in Chrome and Firefox.
*/
progress {
vertical-align: baseline;
}
progress {
vertical-align: baseline;
}
/**
/**
Correct the cursor style of increment and decrement buttons in Safari.
*/
::-webkit-inner-spin-button,
::-webkit-outer-spin-button {
height: auto;
}
::-webkit-inner-spin-button,
::-webkit-outer-spin-button {
height: auto;
}
/**
/**
1. Correct the odd appearance in Chrome and Safari.
2. Correct the outline style in Safari.
*/
[type='search'] {
-webkit-appearance: textfield; /* 1 */
outline-offset: -2px; /* 2 */
}
[type='search'] {
-webkit-appearance: textfield; /* 1 */
outline-offset: -2px; /* 2 */
}
/**
/**
Remove the inner padding in Chrome and Safari on macOS.
*/
::-webkit-search-decoration {
-webkit-appearance: none;
}
::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
/**
1. Correct the inability to style clickable types in iOS and Safari.
2. Change font properties to 'inherit' in Safari.
*/
::-webkit-file-upload-button {
-webkit-appearance: button; /* 1 */
font: inherit; /* 2 */
}
::-webkit-file-upload-button {
-webkit-appearance: button; /* 1 */
font: inherit; /* 2 */
}
/*
/*
Interactive
===========
*/
/*
/*
Add the correct display in Chrome and Safari.
*/
summary {
display: list-item;
summary {
display: list-item;
}
}