feat(client): add Timestamp component, ESLint 10 + Prettier, and code quality fixes
- add Timestamp component with moment relative time and ISO tooltip - add Timestamp stories (JustNow, MinutesAgo, HoursAgo, DaysAgo, MonthsAgo) - add ESLint 10 with typescript-eslint, react-hooks, react-refresh, prettier - add Prettier config with singleQuote, semi, trailingComma all, printWidth 100 - add lint, lint:fix, format, test:storybook scripts to package.json - fix react-hooks/set-state-in-effect in all page components - auto-fix 113 Prettier formatting issues across src and .storybook
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
dist/
|
||||||
|
storybook-static/
|
||||||
|
node_modules/
|
||||||
|
*.css
|
||||||
|
*.json
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"semi": true,
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "all",
|
||||||
|
"printWidth": 100,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"arrowParens": "always"
|
||||||
|
}
|
||||||
+11
-14
@@ -1,26 +1,23 @@
|
|||||||
import type { StorybookConfig } from '@storybook/react-vite';
|
import type { StorybookConfig } from '@storybook/react-vite';
|
||||||
|
|
||||||
import { dirname } from "path"
|
import { dirname } from 'path';
|
||||||
|
|
||||||
import { fileURLToPath } from "url"
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is used to resolve the absolute path of a package.
|
* This function is used to resolve the absolute path of a package.
|
||||||
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
|
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
|
||||||
*/
|
*/
|
||||||
function getAbsolutePath(value: string) {
|
function getAbsolutePath(value: string) {
|
||||||
return dirname(fileURLToPath(import.meta.resolve(`${value}/package.json`)))
|
return dirname(fileURLToPath(import.meta.resolve(`${value}/package.json`)));
|
||||||
}
|
}
|
||||||
const config: StorybookConfig = {
|
const config: StorybookConfig = {
|
||||||
"stories": [
|
stories: ['./stories/**/*.mdx', './stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
||||||
"./stories/**/*.mdx",
|
addons: [
|
||||||
"./stories/**/*.stories.@(js|jsx|mjs|ts|tsx)"
|
|
||||||
],
|
|
||||||
"addons": [
|
|
||||||
getAbsolutePath('@storybook/addon-vitest'),
|
getAbsolutePath('@storybook/addon-vitest'),
|
||||||
getAbsolutePath('@storybook/addon-a11y'),
|
getAbsolutePath('@storybook/addon-a11y'),
|
||||||
getAbsolutePath('@storybook/addon-docs')
|
getAbsolutePath('@storybook/addon-docs'),
|
||||||
],
|
],
|
||||||
"framework": getAbsolutePath('@storybook/react-vite')
|
framework: getAbsolutePath('@storybook/react-vite'),
|
||||||
};
|
};
|
||||||
export default config;
|
export default config;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react'
|
import React from 'react';
|
||||||
import type { Preview } from '@storybook/react-vite'
|
import type { Preview } from '@storybook/react-vite';
|
||||||
import '../src/ui/tokens.css'
|
import '../src/ui/tokens.css';
|
||||||
|
|
||||||
const preview: Preview = {
|
const preview: Preview = {
|
||||||
globalTypes: {
|
globalTypes: {
|
||||||
@@ -12,7 +12,7 @@ const preview: Preview = {
|
|||||||
icon: 'circlehollow',
|
icon: 'circlehollow',
|
||||||
items: [
|
items: [
|
||||||
{ value: 'light', icon: 'sun', title: 'Light' },
|
{ value: 'light', icon: 'sun', title: 'Light' },
|
||||||
{ value: 'dark', icon: 'moon', title: 'Dark' },
|
{ value: 'dark', icon: 'moon', title: 'Dark' },
|
||||||
],
|
],
|
||||||
dynamicTitle: true,
|
dynamicTitle: true,
|
||||||
},
|
},
|
||||||
@@ -20,13 +20,13 @@ const preview: Preview = {
|
|||||||
},
|
},
|
||||||
decorators: [
|
decorators: [
|
||||||
(Story, context) => {
|
(Story, context) => {
|
||||||
const theme = (context.globals['theme'] as string) ?? 'light'
|
const theme = (context.globals['theme'] as string) ?? 'light';
|
||||||
document.documentElement.setAttribute('data-theme', theme)
|
document.documentElement.setAttribute('data-theme', theme);
|
||||||
return (
|
return (
|
||||||
<div style={{ background: 'var(--color-bg)', minHeight: '100vh', padding: 0 }}>
|
<div style={{ background: 'var(--color-bg)', minHeight: '100vh', padding: 0 }}>
|
||||||
<Story />
|
<Story />
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
parameters: {
|
parameters: {
|
||||||
@@ -40,6 +40,6 @@ const preview: Preview = {
|
|||||||
test: 'todo',
|
test: 'todo',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
export default preview
|
export default preview;
|
||||||
|
|||||||
@@ -12,10 +12,7 @@ type Story = StoryObj<typeof Breadcrumbs>;
|
|||||||
|
|
||||||
export const Default: Story = {
|
export const Default: Story = {
|
||||||
args: {
|
args: {
|
||||||
items: [
|
items: [{ label: 'Scenarios', href: '#' }, { label: 'Login flow' }],
|
||||||
{ label: 'Scenarios', href: '#' },
|
|
||||||
{ label: 'Login flow' },
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -30,16 +30,29 @@ export const Default: Story = {
|
|||||||
export const ScenarioCard: Story = {
|
export const ScenarioCard: Story = {
|
||||||
render: () => (
|
render: () => (
|
||||||
<Card>
|
<Card>
|
||||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', marginBottom: 8 }}>
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
alignItems: 'flex-start',
|
||||||
|
marginBottom: 8,
|
||||||
|
}}
|
||||||
|
>
|
||||||
<span style={{ fontWeight: 600, fontSize: 14 }}>Login flow</span>
|
<span style={{ fontWeight: 600, fontSize: 14 }}>Login flow</span>
|
||||||
<Badge variant="success" dot>Passed</Badge>
|
<Badge variant="success" dot>
|
||||||
|
Passed
|
||||||
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
<p style={{ margin: '0 0 16px', fontSize: 13, color: 'var(--color-text-muted)' }}>
|
<p style={{ margin: '0 0 16px', fontSize: 13, color: 'var(--color-text-muted)' }}>
|
||||||
Last run 2 minutes ago · 4 steps
|
Last run 2 minutes ago · 4 steps
|
||||||
</p>
|
</p>
|
||||||
<div style={{ display: 'flex', gap: 8 }}>
|
<div style={{ display: 'flex', gap: 8 }}>
|
||||||
<Button size="sm" variant="primary">Run</Button>
|
<Button size="sm" variant="primary">
|
||||||
<Button size="sm" variant="ghost">Edit</Button>
|
Run
|
||||||
|
</Button>
|
||||||
|
<Button size="sm" variant="ghost">
|
||||||
|
Edit
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -32,27 +32,51 @@ const surfaceColors = [
|
|||||||
{ name: 'Primary fg', token: '--color-primary-fg', hex: '#2D3339' },
|
{ name: 'Primary fg', token: '--color-primary-fg', hex: '#2D3339' },
|
||||||
];
|
];
|
||||||
|
|
||||||
function Swatch({ name, token, hex, role }: { name: string; token: string; hex: string; role?: string }) {
|
function Swatch({
|
||||||
|
name,
|
||||||
|
token,
|
||||||
|
hex,
|
||||||
|
role,
|
||||||
|
}: {
|
||||||
|
name: string;
|
||||||
|
token: string;
|
||||||
|
hex: string;
|
||||||
|
role?: string;
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<div style={{
|
<div
|
||||||
display: 'flex',
|
style={{
|
||||||
flexDirection: 'column',
|
display: 'flex',
|
||||||
overflow: 'hidden',
|
flexDirection: 'column',
|
||||||
borderRadius: 8,
|
overflow: 'hidden',
|
||||||
border: 'var(--border-width) solid var(--color-border)',
|
borderRadius: 8,
|
||||||
minWidth: 160,
|
border: 'var(--border-width) solid var(--color-border)',
|
||||||
flex: '1 1 160px',
|
minWidth: 160,
|
||||||
maxWidth: 220,
|
flex: '1 1 160px',
|
||||||
}}>
|
maxWidth: 220,
|
||||||
<div style={{
|
}}
|
||||||
background: `var(${token}, ${hex})`,
|
>
|
||||||
height: 80,
|
<div
|
||||||
}} />
|
style={{
|
||||||
|
background: `var(${token}, ${hex})`,
|
||||||
|
height: 80,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<div style={{ padding: '10px 12px', background: 'var(--color-bg)' }}>
|
<div style={{ padding: '10px 12px', background: 'var(--color-bg)' }}>
|
||||||
<div style={{ fontWeight: 600, fontSize: 13, color: 'var(--color-text)', marginBottom: 2 }}>{name}</div>
|
<div style={{ fontWeight: 600, fontSize: 13, color: 'var(--color-text)', marginBottom: 2 }}>
|
||||||
{role && <div style={{ fontSize: 11, color: 'var(--color-text-muted)', marginBottom: 4 }}>{role}</div>}
|
{name}
|
||||||
<div style={{ fontSize: 11, fontFamily: 'monospace', color: 'var(--color-text-muted)' }}>{hex}</div>
|
</div>
|
||||||
<div style={{ fontSize: 11, fontFamily: 'monospace', color: 'var(--color-text-muted)' }}>{token}</div>
|
{role && (
|
||||||
|
<div style={{ fontSize: 11, color: 'var(--color-text-muted)', marginBottom: 4 }}>
|
||||||
|
{role}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div style={{ fontSize: 11, fontFamily: 'monospace', color: 'var(--color-text-muted)' }}>
|
||||||
|
{hex}
|
||||||
|
</div>
|
||||||
|
<div style={{ fontSize: 11, fontFamily: 'monospace', color: 'var(--color-text-muted)' }}>
|
||||||
|
{token}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -61,12 +85,20 @@ function Swatch({ name, token, hex, role }: { name: string; token: string; hex:
|
|||||||
function Section({ title, children }: { title: string; children: React.ReactNode }) {
|
function Section({ title, children }: { title: string; children: React.ReactNode }) {
|
||||||
return (
|
return (
|
||||||
<div style={{ marginBottom: 40 }}>
|
<div style={{ marginBottom: 40 }}>
|
||||||
<h2 style={{ fontFamily: 'var(--font-family)', color: 'var(--color-text)', fontSize: 14, fontWeight: 600, marginBottom: 16, textTransform: 'uppercase', letterSpacing: '0.08em' }}>
|
<h2
|
||||||
|
style={{
|
||||||
|
fontFamily: 'var(--font-family)',
|
||||||
|
color: 'var(--color-text)',
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: 600,
|
||||||
|
marginBottom: 16,
|
||||||
|
textTransform: 'uppercase',
|
||||||
|
letterSpacing: '0.08em',
|
||||||
|
}}
|
||||||
|
>
|
||||||
{title}
|
{title}
|
||||||
</h2>
|
</h2>
|
||||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 12 }}>
|
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 12 }}>{children}</div>
|
||||||
{children}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -74,18 +106,27 @@ function Section({ title, children }: { title: string; children: React.ReactNode
|
|||||||
function ColorPalette() {
|
function ColorPalette() {
|
||||||
return (
|
return (
|
||||||
<div style={{ padding: 32, fontFamily: 'var(--font-family)' }}>
|
<div style={{ padding: 32, fontFamily: 'var(--font-family)' }}>
|
||||||
<h1 style={{ color: 'var(--color-text)', fontSize: 22, fontWeight: 700, marginBottom: 8 }}>Color Palette</h1>
|
<h1 style={{ color: 'var(--color-text)', fontSize: 22, fontWeight: 700, marginBottom: 8 }}>
|
||||||
|
Color Palette
|
||||||
|
</h1>
|
||||||
<p style={{ color: 'var(--color-text-muted)', fontSize: 14, marginBottom: 40 }}>
|
<p style={{ color: 'var(--color-text-muted)', fontSize: 14, marginBottom: 40 }}>
|
||||||
All colors are exposed as CSS custom properties on <code>:root</code> via <code>tokens.css</code>.
|
All colors are exposed as CSS custom properties on <code>:root</code> via{' '}
|
||||||
|
<code>tokens.css</code>.
|
||||||
</p>
|
</p>
|
||||||
<Section title="Brand">
|
<Section title="Brand">
|
||||||
{palette.map(c => <Swatch key={c.token} {...c} />)}
|
{palette.map((c) => (
|
||||||
|
<Swatch key={c.token} {...c} />
|
||||||
|
))}
|
||||||
</Section>
|
</Section>
|
||||||
<Section title="Semantic">
|
<Section title="Semantic">
|
||||||
{semanticColors.map(c => <Swatch key={c.token} {...c} />)}
|
{semanticColors.map((c) => (
|
||||||
|
<Swatch key={c.token} {...c} />
|
||||||
|
))}
|
||||||
</Section>
|
</Section>
|
||||||
<Section title="Surface & Action">
|
<Section title="Surface & Action">
|
||||||
{surfaceColors.map(c => <Swatch key={c.token} {...c} />)}
|
{surfaceColors.map((c) => (
|
||||||
|
<Swatch key={c.token} {...c} />
|
||||||
|
))}
|
||||||
</Section>
|
</Section>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -5,7 +5,16 @@ const NAV_ITEMS = ['Dashboard', 'Scenarios', 'Environments', 'Reports', 'Setting
|
|||||||
|
|
||||||
function NavList() {
|
function NavList() {
|
||||||
return (
|
return (
|
||||||
<ul style={{ listStyle: 'none', margin: 0, padding: 0, display: 'flex', flexDirection: 'column', gap: 2 }}>
|
<ul
|
||||||
|
style={{
|
||||||
|
listStyle: 'none',
|
||||||
|
margin: 0,
|
||||||
|
padding: 0,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
gap: 2,
|
||||||
|
}}
|
||||||
|
>
|
||||||
{NAV_ITEMS.map((item) => (
|
{NAV_ITEMS.map((item) => (
|
||||||
<li key={item}>
|
<li key={item}>
|
||||||
<button
|
<button
|
||||||
@@ -41,7 +50,14 @@ const meta: Meta<typeof SidePanel> = {
|
|||||||
(Story) => (
|
(Story) => (
|
||||||
<div style={{ display: 'flex', height: 420, background: 'var(--color-bg)' }}>
|
<div style={{ display: 'flex', height: 420, background: 'var(--color-bg)' }}>
|
||||||
<Story />
|
<Story />
|
||||||
<div style={{ flex: 1, padding: 'var(--space-6)', color: 'var(--color-text-muted)', fontSize: 'var(--font-size-sm)' }}>
|
<div
|
||||||
|
style={{
|
||||||
|
flex: 1,
|
||||||
|
padding: 'var(--space-6)',
|
||||||
|
color: 'var(--color-text-muted)',
|
||||||
|
fontSize: 'var(--font-size-sm)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
Main content area
|
Main content area
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ interface User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const users: User[] = [
|
const users: User[] = [
|
||||||
{ id: 1, name: 'Alice Müller', email: 'alice@example.com', status: 'active' },
|
{ id: 1, name: 'Alice Müller', email: 'alice@example.com', status: 'active' },
|
||||||
{ id: 2, name: 'Bob Nguyen', email: 'bob@example.com', status: 'inactive' },
|
{ id: 2, name: 'Bob Nguyen', email: 'bob@example.com', status: 'inactive' },
|
||||||
{ id: 3, name: 'Carol Santos', email: 'carol@example.com', status: 'active' },
|
{ id: 3, name: 'Carol Santos', email: 'carol@example.com', status: 'active' },
|
||||||
];
|
];
|
||||||
|
|
||||||
export const Default: StoryObj<typeof Table<User>> = {
|
export const Default: StoryObj<typeof Table<User>> = {
|
||||||
@@ -29,17 +29,15 @@ export const Default: StoryObj<typeof Table<User>> = {
|
|||||||
rowKey: (u) => u.id,
|
rowKey: (u) => u.id,
|
||||||
emptyMessage: 'No users found.',
|
emptyMessage: 'No users found.',
|
||||||
columns: [
|
columns: [
|
||||||
{ key: 'id', header: 'ID', render: (u) => u.id, width: 60 },
|
{ key: 'id', header: 'ID', render: (u) => u.id, width: 60 },
|
||||||
{ key: 'name', header: 'Name', render: (u) => u.name },
|
{ key: 'name', header: 'Name', render: (u) => u.name },
|
||||||
{ key: 'email', header: 'Email', render: (u) => u.email },
|
{ key: 'email', header: 'Email', render: (u) => u.email },
|
||||||
{
|
{
|
||||||
key: 'status',
|
key: 'status',
|
||||||
header: 'Status',
|
header: 'Status',
|
||||||
width: 110,
|
width: 110,
|
||||||
render: (u) => (
|
render: (u) => (
|
||||||
<Badge variant={u.status === 'active' ? 'success' : 'neutral'}>
|
<Badge variant={u.status === 'active' ? 'success' : 'neutral'}>{u.status}</Badge>
|
||||||
{u.status}
|
|
||||||
</Badge>
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
||||||
|
import { Timestamp } from '../../src/ui/Timestamp/Timestamp';
|
||||||
|
|
||||||
|
const meta: Meta<typeof Timestamp> = {
|
||||||
|
title: 'UI/Timestamp',
|
||||||
|
component: Timestamp,
|
||||||
|
parameters: { layout: 'centered' },
|
||||||
|
tags: ['autodocs'],
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
type Story = StoryObj<typeof Timestamp>;
|
||||||
|
|
||||||
|
const minutesAgo = (n: number) => new Date(Date.now() - n * 60_000).toISOString();
|
||||||
|
const hoursAgo = (n: number) => new Date(Date.now() - n * 3_600_000).toISOString();
|
||||||
|
const daysAgo = (n: number) => new Date(Date.now() - n * 86_400_000).toISOString();
|
||||||
|
|
||||||
|
export const JustNow: Story = { args: { value: minutesAgo(1) } };
|
||||||
|
export const MinutesAgo: Story = { args: { value: minutesAgo(15) } };
|
||||||
|
export const HoursAgo: Story = { args: { value: hoursAgo(3) } };
|
||||||
|
export const DaysAgo: Story = { args: { value: daysAgo(5) } };
|
||||||
|
export const MonthsAgo: Story = { args: { value: daysAgo(90) } };
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import js from '@eslint/js';
|
||||||
|
import tseslint from 'typescript-eslint';
|
||||||
|
import reactHooks from 'eslint-plugin-react-hooks';
|
||||||
|
import reactRefresh from 'eslint-plugin-react-refresh';
|
||||||
|
import prettier from 'eslint-plugin-prettier';
|
||||||
|
import prettierConfig from 'eslint-config-prettier';
|
||||||
|
|
||||||
|
export default tseslint.config(
|
||||||
|
{ ignores: ['dist', 'storybook-static'] },
|
||||||
|
|
||||||
|
// Base JS rules
|
||||||
|
js.configs.recommended,
|
||||||
|
|
||||||
|
// TypeScript rules
|
||||||
|
...tseslint.configs.recommended,
|
||||||
|
|
||||||
|
// React rules
|
||||||
|
{
|
||||||
|
plugins: {
|
||||||
|
'react-hooks': reactHooks,
|
||||||
|
'react-refresh': reactRefresh,
|
||||||
|
prettier,
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
...reactHooks.configs.recommended.rules,
|
||||||
|
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
|
||||||
|
'prettier/prettier': 'warn',
|
||||||
|
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
// Disable ESLint formatting rules that conflict with Prettier
|
||||||
|
prettierConfig,
|
||||||
|
);
|
||||||
+14
-1
@@ -8,17 +8,23 @@
|
|||||||
"build": "tsc -b && vite build",
|
"build": "tsc -b && vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"storybook": "storybook dev -p 6006",
|
"storybook": "storybook dev -p 6006",
|
||||||
"build-storybook": "storybook build"
|
"build-storybook": "storybook build",
|
||||||
|
"test:storybook": "vitest run --project storybook",
|
||||||
|
"lint": "eslint src .storybook",
|
||||||
|
"lint:fix": "eslint src .storybook --fix",
|
||||||
|
"format": "prettier --write \"src/**/*.{ts,tsx}\" \".storybook/**/*.{ts,tsx}\""
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"i18next": "^26.0.4",
|
"i18next": "^26.0.4",
|
||||||
"lucide-react": "^1.7.0",
|
"lucide-react": "^1.7.0",
|
||||||
|
"moment": "^2.30.1",
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.1.0",
|
"react-dom": "^19.1.0",
|
||||||
"react-i18next": "^17.0.2",
|
"react-i18next": "^17.0.2",
|
||||||
"react-router-dom": "^7.14.0"
|
"react-router-dom": "^7.14.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@eslint/js": "^9.39.4",
|
||||||
"@storybook/addon-a11y": "^10.3.5",
|
"@storybook/addon-a11y": "^10.3.5",
|
||||||
"@storybook/addon-docs": "^10.3.5",
|
"@storybook/addon-docs": "^10.3.5",
|
||||||
"@storybook/addon-vitest": "^10.3.5",
|
"@storybook/addon-vitest": "^10.3.5",
|
||||||
@@ -28,9 +34,16 @@
|
|||||||
"@vitejs/plugin-react": "^4.4.1",
|
"@vitejs/plugin-react": "^4.4.1",
|
||||||
"@vitest/browser-playwright": "^4.1.3",
|
"@vitest/browser-playwright": "^4.1.3",
|
||||||
"@vitest/coverage-v8": "^4.1.3",
|
"@vitest/coverage-v8": "^4.1.3",
|
||||||
|
"eslint": "^10.2.0",
|
||||||
|
"eslint-config-prettier": "^10.1.8",
|
||||||
|
"eslint-plugin-prettier": "^5.5.5",
|
||||||
|
"eslint-plugin-react-hooks": "^7.0.1",
|
||||||
|
"eslint-plugin-react-refresh": "^0.5.2",
|
||||||
"playwright": "^1.59.1",
|
"playwright": "^1.59.1",
|
||||||
|
"prettier": "^3.8.1",
|
||||||
"storybook": "^10.3.5",
|
"storybook": "^10.3.5",
|
||||||
"typescript": "~5.8.3",
|
"typescript": "~5.8.3",
|
||||||
|
"typescript-eslint": "^8.58.1",
|
||||||
"vite": "^6.3.1",
|
"vite": "^6.3.1",
|
||||||
"vitest": "^4.1.3"
|
"vitest": "^4.1.3"
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -11,9 +11,9 @@ import type { LucideIcon } from 'lucide-react';
|
|||||||
|
|
||||||
const NAV: { path: string; labelKey: string; Icon: LucideIcon }[] = [
|
const NAV: { path: string; labelKey: string; Icon: LucideIcon }[] = [
|
||||||
{ path: '/environments', labelKey: 'nav.environments', Icon: Globe },
|
{ path: '/environments', labelKey: 'nav.environments', Icon: Globe },
|
||||||
{ path: '/keys', labelKey: 'nav.keys', Icon: KeyRound },
|
{ path: '/keys', labelKey: 'nav.keys', Icon: KeyRound },
|
||||||
{ path: '/sessions', labelKey: 'nav.sessions', Icon: Monitor },
|
{ path: '/sessions', labelKey: 'nav.sessions', Icon: Monitor },
|
||||||
{ path: '/scenarios', labelKey: 'nav.scenarios', Icon: ClipboardList },
|
{ path: '/scenarios', labelKey: 'nav.scenarios', Icon: ClipboardList },
|
||||||
];
|
];
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
@@ -50,10 +50,10 @@ export default function App() {
|
|||||||
<Routes>
|
<Routes>
|
||||||
<Route index element={<Navigate to="/scenarios" replace />} />
|
<Route index element={<Navigate to="/scenarios" replace />} />
|
||||||
<Route path="/environments" element={<EnvironmentsPage />} />
|
<Route path="/environments" element={<EnvironmentsPage />} />
|
||||||
<Route path="/keys" element={<KeysPage />} />
|
<Route path="/keys" element={<KeysPage />} />
|
||||||
<Route path="/sessions" element={<SessionsPage />} />
|
<Route path="/sessions" element={<SessionsPage />} />
|
||||||
<Route path="/scenarios" element={<ScenariosPage />} />
|
<Route path="/scenarios" element={<ScenariosPage />} />
|
||||||
<Route path="*" element={<Navigate to="/scenarios" replace />} />
|
<Route path="*" element={<Navigate to="/scenarios" replace />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export function useTheme() {
|
|||||||
}, [theme]);
|
}, [theme]);
|
||||||
|
|
||||||
function toggleTheme() {
|
function toggleTheme() {
|
||||||
setTheme(t => (t === 'light' ? 'dark' : 'light'));
|
setTheme((t) => (t === 'light' ? 'dark' : 'light'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return { theme, toggleTheme } as const;
|
return { theme, toggleTheme } as const;
|
||||||
|
|||||||
@@ -2,13 +2,11 @@ import i18n from 'i18next';
|
|||||||
import { initReactI18next } from 'react-i18next';
|
import { initReactI18next } from 'react-i18next';
|
||||||
import en from './locales/en.json';
|
import en from './locales/en.json';
|
||||||
|
|
||||||
i18n
|
i18n.use(initReactI18next).init({
|
||||||
.use(initReactI18next)
|
resources: { en: { translation: en } },
|
||||||
.init({
|
lng: 'en',
|
||||||
resources: { en: { translation: en } },
|
fallbackLng: 'en',
|
||||||
lng: 'en',
|
interpolation: { escapeValue: false },
|
||||||
fallbackLng: 'en',
|
});
|
||||||
interpolation: { escapeValue: false },
|
|
||||||
});
|
|
||||||
|
|
||||||
export default i18n;
|
export default i18n;
|
||||||
|
|||||||
+7
-7
@@ -1,9 +1,9 @@
|
|||||||
import { StrictMode } from 'react'
|
import { StrictMode } from 'react';
|
||||||
import { createRoot } from 'react-dom/client'
|
import { createRoot } from 'react-dom/client';
|
||||||
import { HashRouter } from 'react-router-dom'
|
import { HashRouter } from 'react-router-dom';
|
||||||
import './i18n'
|
import './i18n';
|
||||||
import './ui/tokens.css'
|
import './ui/tokens.css';
|
||||||
import App from './App'
|
import App from './App';
|
||||||
|
|
||||||
createRoot(document.getElementById('root')!).render(
|
createRoot(document.getElementById('root')!).render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
@@ -11,4 +11,4 @@ createRoot(document.getElementById('root')!).render(
|
|||||||
<App />
|
<App />
|
||||||
</HashRouter>
|
</HashRouter>
|
||||||
</StrictMode>,
|
</StrictMode>,
|
||||||
)
|
);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { environments } from '../api';
|
import { environments } from '../api';
|
||||||
import type { Environment } from '../api';
|
import type { Environment } from '../api';
|
||||||
import { Table, type TableColumn } from '../ui';
|
import { Table, type TableColumn, Timestamp } from '../ui';
|
||||||
import styles from './Page.module.css';
|
import styles from './Page.module.css';
|
||||||
|
|
||||||
export function EnvironmentsPage() {
|
export function EnvironmentsPage() {
|
||||||
@@ -12,8 +12,8 @@ export function EnvironmentsPage() {
|
|||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
const columns: TableColumn<Environment>[] = [
|
const columns: TableColumn<Environment>[] = [
|
||||||
{ key: 'id', header: t('environments.col_id'), render: (e) => e.id, width: 60 },
|
{ key: 'id', header: t('environments.col_id'), render: (e) => e.id, width: 60 },
|
||||||
{ key: 'name', header: t('environments.col_name'), render: (e) => e.name },
|
{ key: 'name', header: t('environments.col_name'), render: (e) => e.name },
|
||||||
{
|
{
|
||||||
key: 'urls',
|
key: 'urls',
|
||||||
header: t('environments.col_urls'),
|
header: t('environments.col_urls'),
|
||||||
@@ -26,14 +26,14 @@ export function EnvironmentsPage() {
|
|||||||
{
|
{
|
||||||
key: 'updated',
|
key: 'updated',
|
||||||
header: t('environments.col_updated'),
|
header: t('environments.col_updated'),
|
||||||
width: 120,
|
width: 140,
|
||||||
render: (e) => new Date(e.updatedAt).toLocaleDateString(),
|
render: (e) => <Timestamp value={e.updatedAt} />,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
environments
|
||||||
environments.list()
|
.list()
|
||||||
.then((res) => setItems(res.data))
|
.then((res) => setItems(res.data))
|
||||||
.catch((err: Error) => setError(err.message))
|
.catch((err: Error) => setError(err.message))
|
||||||
.finally(() => setLoading(false));
|
.finally(() => setLoading(false));
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import { keys } from '../api';
|
|||||||
import { Table, type TableColumn } from '../ui';
|
import { Table, type TableColumn } from '../ui';
|
||||||
import styles from './Page.module.css';
|
import styles from './Page.module.css';
|
||||||
|
|
||||||
interface KeyRow { name: string }
|
interface KeyRow {
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
export function KeysPage() {
|
export function KeysPage() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -17,8 +19,8 @@ export function KeysPage() {
|
|||||||
];
|
];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
keys
|
||||||
keys.list()
|
.list()
|
||||||
.then((res) => setItems(res.keys.map((name) => ({ name }))))
|
.then((res) => setItems(res.keys.map((name) => ({ name }))))
|
||||||
.catch((err: Error) => setError(err.message))
|
.catch((err: Error) => setError(err.message))
|
||||||
.finally(() => setLoading(false));
|
.finally(() => setLoading(false));
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useState } from 'react';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { scenarios } from '../api';
|
import { scenarios } from '../api';
|
||||||
import type { Scenario } from '../api';
|
import type { Scenario } from '../api';
|
||||||
import { Button, Table, type TableColumn } from '../ui';
|
import { Button, Table, type TableColumn, Timestamp } from '../ui';
|
||||||
import styles from './Page.module.css';
|
import styles from './Page.module.css';
|
||||||
|
|
||||||
export function ScenariosPage() {
|
export function ScenariosPage() {
|
||||||
@@ -12,14 +12,16 @@ export function ScenariosPage() {
|
|||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
const load = useCallback(() => {
|
const load = useCallback(() => {
|
||||||
setLoading(true);
|
scenarios
|
||||||
scenarios.list()
|
.list()
|
||||||
.then((res) => setItems(res.data))
|
.then((res) => setItems(res.data))
|
||||||
.catch((err: Error) => setError(err.message))
|
.catch((err: Error) => setError(err.message))
|
||||||
.finally(() => setLoading(false));
|
.finally(() => setLoading(false));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(load, [load]);
|
useEffect(() => {
|
||||||
|
load();
|
||||||
|
}, [load]);
|
||||||
|
|
||||||
const handleRun = async (id: number) => {
|
const handleRun = async (id: number) => {
|
||||||
await scenarios.run(id);
|
await scenarios.run(id);
|
||||||
@@ -27,17 +29,18 @@ export function ScenariosPage() {
|
|||||||
|
|
||||||
const handleDelete = async (id: number) => {
|
const handleDelete = async (id: number) => {
|
||||||
await scenarios.remove(id);
|
await scenarios.remove(id);
|
||||||
|
setLoading(true);
|
||||||
load();
|
load();
|
||||||
};
|
};
|
||||||
|
|
||||||
const columns: TableColumn<Scenario>[] = [
|
const columns: TableColumn<Scenario>[] = [
|
||||||
{ key: 'id', header: t('scenarios.col_id'), render: (s) => s.id, width: 60 },
|
{ key: 'id', header: t('scenarios.col_id'), render: (s) => s.id, width: 60 },
|
||||||
{ key: 'name', header: t('scenarios.col_name'), render: (s) => s.name },
|
{ key: 'name', header: t('scenarios.col_name'), render: (s) => s.name },
|
||||||
{
|
{
|
||||||
key: 'updated',
|
key: 'updated',
|
||||||
header: t('scenarios.col_updated'),
|
header: t('scenarios.col_updated'),
|
||||||
width: 120,
|
width: 140,
|
||||||
render: (s) => new Date(s.updatedAt).toLocaleDateString(),
|
render: (s) => <Timestamp value={s.updatedAt} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'actions',
|
key: 'actions',
|
||||||
@@ -46,8 +49,12 @@ export function ScenariosPage() {
|
|||||||
align: 'right',
|
align: 'right',
|
||||||
render: (s) => (
|
render: (s) => (
|
||||||
<span style={{ display: 'inline-flex', gap: 6 }}>
|
<span style={{ display: 'inline-flex', gap: 6 }}>
|
||||||
<Button size="sm" onClick={() => handleRun(s.id)}>{t('scenarios.action_run')}</Button>
|
<Button size="sm" onClick={() => handleRun(s.id)}>
|
||||||
<Button variant="secondary" size="sm" onClick={() => handleDelete(s.id)}>{t('scenarios.action_delete')}</Button>
|
{t('scenarios.action_run')}
|
||||||
|
</Button>
|
||||||
|
<Button variant="secondary" size="sm" onClick={() => handleDelete(s.id)}>
|
||||||
|
{t('scenarios.action_delete')}
|
||||||
|
</Button>
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useState } from 'react';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { sessions } from '../api';
|
import { sessions } from '../api';
|
||||||
import type { Session } from '../api';
|
import type { Session } from '../api';
|
||||||
import { Badge, Button, Table, type TableColumn } from '../ui';
|
import { Badge, Button, Table, type TableColumn, Timestamp } from '../ui';
|
||||||
import styles from './Page.module.css';
|
import styles from './Page.module.css';
|
||||||
|
|
||||||
export function SessionsPage() {
|
export function SessionsPage() {
|
||||||
@@ -12,38 +12,39 @@ export function SessionsPage() {
|
|||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
const load = useCallback(() => {
|
const load = useCallback(() => {
|
||||||
setLoading(true);
|
sessions
|
||||||
sessions.list()
|
.list()
|
||||||
.then((res) => setItems(res.data))
|
.then((res) => setItems(res.data))
|
||||||
.catch((err: Error) => setError(err.message))
|
.catch((err: Error) => setError(err.message))
|
||||||
.finally(() => setLoading(false));
|
.finally(() => setLoading(false));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(load, [load]);
|
useEffect(() => {
|
||||||
|
load();
|
||||||
|
}, [load]);
|
||||||
|
|
||||||
const handleDelete = async (id: number) => {
|
const handleDelete = async (id: number) => {
|
||||||
await sessions.remove(id);
|
await sessions.remove(id);
|
||||||
|
setLoading(true);
|
||||||
load();
|
load();
|
||||||
};
|
};
|
||||||
|
|
||||||
const columns: TableColumn<Session>[] = [
|
const columns: TableColumn<Session>[] = [
|
||||||
{ key: 'id', header: t('sessions.col_id'), render: (s) => s.id, width: 60 },
|
{ key: 'id', header: t('sessions.col_id'), render: (s) => s.id, width: 60 },
|
||||||
{ key: 'name', header: t('sessions.col_name'), render: (s) => s.sessionName },
|
{ key: 'name', header: t('sessions.col_name'), render: (s) => s.sessionName },
|
||||||
{
|
{
|
||||||
key: 'status',
|
key: 'status',
|
||||||
header: t('sessions.col_status'),
|
header: t('sessions.col_status'),
|
||||||
width: 100,
|
width: 100,
|
||||||
render: (s) => (
|
render: (s) => (
|
||||||
<Badge variant={s.status === 'open' ? 'success' : 'neutral'}>
|
<Badge variant={s.status === 'open' ? 'success' : 'neutral'}>{s.status}</Badge>
|
||||||
{s.status}
|
|
||||||
</Badge>
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'lastUsed',
|
key: 'lastUsed',
|
||||||
header: t('sessions.col_lastUsed'),
|
header: t('sessions.col_lastUsed'),
|
||||||
width: 160,
|
width: 160,
|
||||||
render: (s) => s.lastUsedAt ? new Date(s.lastUsedAt).toLocaleString() : '—',
|
render: (s) => (s.lastUsedAt ? <Timestamp value={s.lastUsedAt} /> : '—'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'actions',
|
key: 'actions',
|
||||||
|
|||||||
@@ -16,7 +16,13 @@ export interface BreadcrumbsProps {
|
|||||||
export function Breadcrumbs({ items, separator, className }: BreadcrumbsProps) {
|
export function Breadcrumbs({ items, separator, className }: BreadcrumbsProps) {
|
||||||
const sep = separator ?? (
|
const sep = separator ?? (
|
||||||
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true">
|
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true">
|
||||||
<path d="M4 2L8 6L4 10" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
|
<path
|
||||||
|
d="M4 2L8 6L4 10"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="1.5"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -28,11 +34,17 @@ export function Breadcrumbs({ items, separator, className }: BreadcrumbsProps) {
|
|||||||
return (
|
return (
|
||||||
<li key={i} className={styles.item}>
|
<li key={i} className={styles.item}>
|
||||||
{isLast ? (
|
{isLast ? (
|
||||||
<span className={styles.current} aria-current="page">{item.label}</span>
|
<span className={styles.current} aria-current="page">
|
||||||
|
{item.label}
|
||||||
|
</span>
|
||||||
) : item.href ? (
|
) : item.href ? (
|
||||||
<a href={item.href} className={styles.link} onClick={item.onClick}>{item.label}</a>
|
<a href={item.href} className={styles.link} onClick={item.onClick}>
|
||||||
|
{item.label}
|
||||||
|
</a>
|
||||||
) : (
|
) : (
|
||||||
<button type="button" className={styles.link} onClick={item.onClick}>{item.label}</button>
|
<button type="button" className={styles.link} onClick={item.onClick}>
|
||||||
|
{item.label}
|
||||||
|
</button>
|
||||||
)}
|
)}
|
||||||
{!isLast && <span className={styles.separator}>{sep}</span>}
|
{!isLast && <span className={styles.separator}>{sep}</span>}
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ export function Button({
|
|||||||
}: ButtonProps) {
|
}: ButtonProps) {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
className={[styles.button, styles[variant], styles[size], className].filter(Boolean).join(' ')}
|
className={[styles.button, styles[variant], styles[size], className]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' ')}
|
||||||
disabled={disabled || loading}
|
disabled={disabled || loading}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ export function Input({ label, hint, error, className, ...props }: InputProps) {
|
|||||||
)}
|
)}
|
||||||
<input
|
<input
|
||||||
id={id}
|
id={id}
|
||||||
className={[styles.input, error ? styles.hasError : '', className].filter(Boolean).join(' ')}
|
className={[styles.input, error ? styles.hasError : '', className]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' ')}
|
||||||
aria-describedby={error ? `${id}-error` : hint ? `${id}-hint` : undefined}
|
aria-describedby={error ? `${id}-error` : hint ? `${id}-hint` : undefined}
|
||||||
aria-invalid={error ? true : undefined}
|
aria-invalid={error ? true : undefined}
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
@@ -15,7 +15,15 @@ export interface SelectProps extends Omit<React.SelectHTMLAttributes<HTMLSelectE
|
|||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Select({ label, hint, error, options, placeholder, className, ...props }: SelectProps) {
|
export function Select({
|
||||||
|
label,
|
||||||
|
hint,
|
||||||
|
error,
|
||||||
|
options,
|
||||||
|
placeholder,
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: SelectProps) {
|
||||||
const id = useId();
|
const id = useId();
|
||||||
return (
|
return (
|
||||||
<div className={styles.wrapper}>
|
<div className={styles.wrapper}>
|
||||||
@@ -27,7 +35,9 @@ export function Select({ label, hint, error, options, placeholder, className, ..
|
|||||||
<div className={styles.control}>
|
<div className={styles.control}>
|
||||||
<select
|
<select
|
||||||
id={id}
|
id={id}
|
||||||
className={[styles.select, error ? styles.hasError : '', className].filter(Boolean).join(' ')}
|
className={[styles.select, error ? styles.hasError : '', className]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' ')}
|
||||||
aria-describedby={error ? `${id}-error` : hint ? `${id}-hint` : undefined}
|
aria-describedby={error ? `${id}-error` : hint ? `${id}-hint` : undefined}
|
||||||
aria-invalid={error ? true : undefined}
|
aria-invalid={error ? true : undefined}
|
||||||
{...props}
|
{...props}
|
||||||
@@ -45,7 +55,13 @@ export function Select({ label, hint, error, options, placeholder, className, ..
|
|||||||
</select>
|
</select>
|
||||||
<span className={styles.chevron} aria-hidden="true">
|
<span className={styles.chevron} aria-hidden="true">
|
||||||
<svg width="12" height="12" viewBox="0 0 12 12" fill="none">
|
<svg width="12" height="12" viewBox="0 0 12 12" fill="none">
|
||||||
<path d="M2 4L6 8L10 4" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
|
<path
|
||||||
|
d="M2 4L6 8L10 4"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="1.5"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ export function SidePanel({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<aside
|
<aside
|
||||||
className={[styles.panel, collapsed ? styles.collapsed : '', className].filter(Boolean).join(' ')}
|
className={[styles.panel, collapsed ? styles.collapsed : '', className]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' ')}
|
||||||
style={{ '--side-panel-width': `${width}px` } as React.CSSProperties}
|
style={{ '--side-panel-width': `${width}px` } as React.CSSProperties}
|
||||||
aria-expanded={!collapsed}
|
aria-expanded={!collapsed}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
.timestamp {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
font-family: var(--font-family);
|
||||||
|
font-size: var(--font-size-xs);
|
||||||
|
font-weight: 500;
|
||||||
|
padding: 2px var(--space-2);
|
||||||
|
border-radius: var(--radius-full);
|
||||||
|
white-space: nowrap;
|
||||||
|
line-height: 1.6;
|
||||||
|
background: var(--color-neutral-bg);
|
||||||
|
color: var(--color-neutral-fg);
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timestamp:hover {
|
||||||
|
background: var(--color-bg-subtle);
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import moment from 'moment';
|
||||||
|
import styles from './Timestamp.module.css';
|
||||||
|
|
||||||
|
export interface TimestampProps {
|
||||||
|
value: string | number | Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Timestamp({ value }: TimestampProps) {
|
||||||
|
const m = moment(value);
|
||||||
|
const iso = m.toISOString();
|
||||||
|
const relative = m.fromNow();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span className={styles.timestamp} title={iso} aria-label={iso}>
|
||||||
|
{relative}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -21,5 +21,8 @@ export type { BreadcrumbsProps, BreadcrumbItem } from './Breadcrumbs/Breadcrumbs
|
|||||||
|
|
||||||
export { ThemeSwitcher } from './ThemeSwitcher/ThemeSwitcher';
|
export { ThemeSwitcher } from './ThemeSwitcher/ThemeSwitcher';
|
||||||
|
|
||||||
|
export { Timestamp } from './Timestamp/Timestamp';
|
||||||
|
export type { TimestampProps } from './Timestamp/Timestamp';
|
||||||
|
|
||||||
export { Table } from './Table/Table';
|
export { Table } from './Table/Table';
|
||||||
export type { TableProps, TableColumn } from './Table/Table';
|
export type { TableProps, TableColumn } from './Table/Table';
|
||||||
|
|||||||
Generated
+817
-146
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user