-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
256 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite + React + TS</title> | ||
</head> | ||
|
||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/dev-server.tsx"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
body { | ||
background: var(--page-background); | ||
color: var(--text-color); | ||
} | ||
|
||
#root { | ||
padding: 2rem 0; | ||
} | ||
|
||
h2 { | ||
text-align: center; | ||
} | ||
|
||
.variable-list { | ||
display: grid; | ||
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); | ||
justify-content: center; | ||
gap: 0.6rem; | ||
|
||
&>.variable-item { | ||
display: flex; | ||
flex-direction: row; | ||
gap: 0.6em; | ||
align-items: center; | ||
|
||
.color-box { | ||
flex: 0 0 30px; | ||
height: 30px; | ||
} | ||
|
||
.data { | ||
display: flex; | ||
flex-direction: column; | ||
flex: 1; | ||
|
||
.variable-name { | ||
font-weight: bold; | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
.nav { | ||
display: flex; | ||
justify-content: center; | ||
gap: 1rem; | ||
margin-top: 1rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { StrictMode } from 'react' | ||
import { createRoot } from 'react-dom/client' | ||
import { | ||
createBrowserRouter, | ||
RouterProvider, | ||
} from "react-router-dom"; | ||
import { Index } from './dev-server/index'; | ||
import './dev-server.css' | ||
import '@inkdropapp/css/reset.css' | ||
import '@inkdropapp/css/tokens.css' | ||
import '@inkdropapp/base-ui-theme/styles/theme.css' | ||
import { ColorTokensPage } from './dev-server/color-tokens'; | ||
import { VariablesPage } from './dev-server/variables'; | ||
|
||
const cssFiles = [ | ||
'/Users/nora/Developments/inkdrop/plugins/solarized-light-ui/styles/tokens.css', | ||
'/Users/nora/Developments/inkdrop/plugins/solarized-light-ui/styles/theme.css' | ||
] | ||
|
||
cssFiles.forEach((file) => { | ||
import( /* @vite-ignore */ file) | ||
}) | ||
|
||
const router = createBrowserRouter([ | ||
{ | ||
path: "/", | ||
element: <Index />, | ||
children: [ | ||
{ path: '', element: <VariablesPage /> }, | ||
{ path: 'tokens', element: <ColorTokensPage /> } | ||
] | ||
}, | ||
]); | ||
|
||
createRoot(document.getElementById('root')!).render( | ||
<StrictMode> | ||
<RouterProvider router={router} /> | ||
</StrictMode>, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { getCSSVariables } from './get-css-variables' | ||
|
||
export const ColorTokensPage = () => { | ||
const cssVariables = getCSSVariables() | ||
|
||
return ( | ||
<> | ||
<h2>Color Tokens</h2> | ||
<div className='variable-list'> | ||
{Object.keys(cssVariables) | ||
.filter(name => name.startsWith('--color') || name.startsWith('--hsl')) | ||
.map(variableName => { | ||
return ( | ||
<div key={variableName} className='variable-item'> | ||
<div className='color-box' style={{ | ||
background: variableName.startsWith('--hsl') ? `hsl(var(${variableName}))` : `var(${variableName})` | ||
}}></div> | ||
<div className='data'> | ||
<div className='variable-name'>{variableName}</div> | ||
<div className='variable-value'> | ||
{cssVariables[variableName]} | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
})} | ||
</div> | ||
</> | ||
) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export function getCSSVariables() { | ||
const computedStyles = document.body.computedStyleMap(); | ||
const variables: Record<string, string> = {}; | ||
for (const [prop, val] of computedStyles) { | ||
if (prop.startsWith('--')) { | ||
variables[prop] = val.toString(); | ||
} | ||
} | ||
|
||
|
||
return variables | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Outlet } from 'react-router-dom' | ||
import { Nav } from './nav' | ||
|
||
export const Index = () => { | ||
return ( | ||
<div className={`ui container`}> | ||
<Nav /> | ||
<Outlet /> | ||
</div> | ||
) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Link } from "react-router-dom"; | ||
|
||
export const Nav = () => { | ||
return ( | ||
<div className='nav'> | ||
<Link to='/'>Variables</Link> | ||
<Link to='/tokens'>Color Tokens</Link> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import themeVariableNames from '@inkdropapp/base-ui-theme/lib/variable-names.json' | ||
import { getCSSVariables } from './get-css-variables' | ||
|
||
export const VariablesPage = () => { | ||
const cssVariables = getCSSVariables() | ||
return ( | ||
<> | ||
<h2>Variables</h2> | ||
<div className='variable-list'> | ||
{themeVariableNames.map(variableName => { | ||
return ( | ||
<div key={variableName} className='variable-item'> | ||
<div className='color-box' style={{ | ||
background: `var(${variableName})` | ||
}}></div> | ||
<div className='data'> | ||
<div className='variable-name'>{variableName}</div> | ||
<div className='variable-value'> | ||
{cssVariables[variableName]} | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
})} | ||
</div> | ||
</> | ||
) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2020", | ||
"useDefineForClassFields": true, | ||
"lib": [ | ||
"ES2020", | ||
"DOM", | ||
"DOM.Iterable" | ||
], | ||
"module": "ESNext", | ||
"skipLibCheck": true, | ||
/* Bundler mode */ | ||
"moduleResolution": "bundler", | ||
"allowImportingTsExtensions": true, | ||
"isolatedModules": true, | ||
"moduleDetection": "force", | ||
"noEmit": true, | ||
"jsx": "react-jsx", | ||
/* Linting */ | ||
"strict": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noFallthroughCasesInSwitch": true | ||
}, | ||
"include": [ | ||
"src" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineConfig } from 'vite' | ||
import react from '@vitejs/plugin-react' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [react()], | ||
server: { | ||
fs: { | ||
allow: ['src', '/Users/nora/'] | ||
} | ||
} | ||
}) |