-
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
5 changed files
with
151 additions
and
1 deletion.
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,22 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Iconic palettes</title> | ||
<link rel="icon" | ||
href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🎨</text></svg>"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta name="author" content="<%= authorName %>"> | ||
<meta name="robots" content="all,follow"> | ||
<meta name="viewport" content="width=device-width,user-scalable=no,minimum-scale=1,maximum-scale=1"> | ||
<meta name="theme-color" content="#ffffff"> | ||
<link href="./style.css" rel="stylesheet"> | ||
</head> | ||
|
||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="./src/index.ts"></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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Scheme } from './../../src/index'; | ||
import { palettes, getPalette } from "../../src/index" | ||
|
||
const div = (className: string): HTMLElement => { | ||
const elem = document.createElement('div'); | ||
elem.className = className; | ||
return elem; | ||
}; | ||
|
||
const colorBlock = (palette: Scheme): HTMLElement => { | ||
const block = div(`palette-block ${palette.theme}`); | ||
block.style.backgroundColor = palette.background; | ||
block.style.color = palette.stroke; | ||
|
||
const colors = div(`colors col-${palette.colors.length}`); | ||
palette.colors.forEach((color) => { | ||
const colDiv = div('color'); | ||
colDiv.style.backgroundColor = color; | ||
colDiv.style.border = `${Math.round(Math.random()*6)}px solid ${palette.stroke}`; | ||
colors.appendChild(colDiv); | ||
}); | ||
const meta = div('palette-meta') | ||
meta.innerHTML = ` | ||
<h3 | ||
title="${palette.meta.title}, ${palette.meta.year}, ${palette.meta.techniques}"> | ||
${palette.meta.artist} | ||
</h3>`; | ||
|
||
block.appendChild(colors); | ||
block.appendChild(meta) | ||
block.addEventListener('click', function () { | ||
navigator.clipboard.writeText(JSON.stringify(palette)); | ||
}); | ||
return block; | ||
}; | ||
|
||
const app = document.getElementById('app'); | ||
if (app !== null) { | ||
palettes.forEach((palette) => app.appendChild(colorBlock(palette))); | ||
} |
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,68 @@ | ||
body { | ||
box-sizing: border-box; | ||
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', | ||
'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', | ||
'Helvetica Neue', Arial, sans-serif; | ||
} | ||
|
||
body, | ||
#app { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
body { | ||
padding: 2em; | ||
} | ||
|
||
#app { | ||
display: grid; | ||
grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); | ||
} | ||
|
||
.palette-block { | ||
display: flex; | ||
text-align: center; | ||
flex-flow: column nowrap; | ||
justify-content: space-between; | ||
padding: 0.5em; | ||
margin: 1em; | ||
text-align: center; | ||
border-radius: 4px; | ||
overflow: hidden; | ||
box-shadow: 0 4px 8px rgb(0 0 0 / 30%); | ||
} | ||
|
||
.palette-block.bright .palette-meta { | ||
background-color: #fefefe; | ||
} | ||
|
||
.palette-block.dark .palette-meta { | ||
background-color: #111111; | ||
} | ||
|
||
.palette-meta h3 { | ||
position: relative; | ||
font-size: 1.4em; | ||
z-index: 2; | ||
} | ||
.oalette-meta p { | ||
position: relative; | ||
font-size: 1em; | ||
margin: 0; | ||
} | ||
|
||
.palette-block .colors { | ||
display: flex; | ||
padding: 1em 0; | ||
width: 100%; | ||
justify-content: space-evenly; | ||
align-items: center; | ||
flex-flow: row nowrap; | ||
} | ||
|
||
.palette-block .colors .color { | ||
height: 3em; | ||
flex-basis: 3em; | ||
margin: 0.33em; | ||
} |
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,18 @@ | ||
// vite.config.ts | ||
import { resolve } from 'path'; | ||
import { defineConfig } from 'vite'; | ||
import dts from 'vite-plugin-dts'; | ||
// https://vitejs.dev/guide/build.html#library-mode | ||
|
||
export default defineConfig({ | ||
build: { | ||
rollupOptions: { | ||
output: { | ||
format: 'iife', | ||
} | ||
}, | ||
outDir: './dist/', | ||
emptyOutDir: true | ||
}, | ||
plugins: [dts()], | ||
}) |
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