-
Notifications
You must be signed in to change notification settings - Fork 4
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
16 changed files
with
499 additions
and
2 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,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
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,27 @@ | ||
import type { StorybookConfig } from "@storybook/web-components-vite"; | ||
import { mergeConfig } from "vite"; | ||
|
||
import autoStoryGenerator from "@takuma-ru/auto-story-generator"; | ||
|
||
const config: StorybookConfig = { | ||
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"], | ||
addons: ["@storybook/addon-links", "@storybook/addon-essentials"], | ||
framework: { | ||
name: "@storybook/web-components-vite", | ||
options: {}, | ||
}, | ||
docs: { | ||
autodocs: "tag", | ||
}, | ||
viteFinal: (config) => { | ||
return mergeConfig(config, { | ||
plugins: [ | ||
autoStoryGenerator.vite({ | ||
preset: "lit", | ||
imports: ["**/src/components/**/*.ce.ts"], | ||
}), | ||
], | ||
}); | ||
}, | ||
}; | ||
export default config; |
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,15 @@ | ||
import type { Preview } from "@storybook/web-components"; | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
actions: { argTypesRegex: "^on[A-Z].*" }, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default preview; |
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 + Lit + TS</title> | ||
<link rel="stylesheet" href="./src/index.css" /> | ||
<script type="module" src="/src/my-element.ts"></script> | ||
</head> | ||
<body> | ||
<my-element> | ||
<h1>Vite + Lit</h1> | ||
</my-element> | ||
</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,29 @@ | ||
{ | ||
"name": "lit", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"preview": "vite preview", | ||
"sb:dev": "storybook dev -p 6006 --no-open", | ||
"sb:build": "storybook build" | ||
}, | ||
"dependencies": { | ||
"@takuma-ru/auto-story-generator": "workspace:^", | ||
"lit": "^3.1.0" | ||
}, | ||
"devDependencies": { | ||
"@storybook/addon-essentials": "^7.6.12", | ||
"@storybook/addon-links": "^7.6.12", | ||
"@storybook/blocks": "^7.6.12", | ||
"@storybook/web-components": "^7.6.12", | ||
"@storybook/web-components-vite": "^7.6.12", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"storybook": "^7.6.12", | ||
"typescript": "^5.2.2", | ||
"vite": "^5.0.8" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
import { LitElement, html } from "lit"; | ||
import { customElement, property } from "lit/decorators.js"; | ||
|
||
export type CeTestAProps = { | ||
propA: string; | ||
}; | ||
|
||
@customElement("vum-button") | ||
export class CeTestA extends LitElement { | ||
@property({ attribute: "prop-a", type: String }) | ||
propA: CeTestAProps["propA"] = "default value"; | ||
|
||
render() { | ||
return html`<div>${this.propA}</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,23 @@ | ||
import { html } from "lit"; | ||
|
||
import type { Meta, StoryObj } from "@storybook/web-components"; | ||
|
||
import { CeTestA, CeTestAProps } from "../ce-test-a/ce-test-a.ce"; | ||
|
||
const meta: Meta<CeTestAProps> = { | ||
title: "components/ce-test-a", | ||
tags: ["autodocs"], | ||
render: (args) => { | ||
new CeTestA(); | ||
|
||
return html`<ce-test-a prop-a="${args.propA}">ce-test-a</ce-test-a>`; | ||
}, | ||
args: { propA: undefined }, | ||
argTypes: { propA: { control: "text" } }, | ||
}; | ||
|
||
export default meta; | ||
|
||
export type CeTestAStory = StoryObj<CeTestAProps>; | ||
|
||
export const Primary: CeTestAStory = {}; |
Empty file.
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,38 @@ | ||
:root { | ||
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; | ||
line-height: 1.5; | ||
font-weight: 400; | ||
|
||
color-scheme: light dark; | ||
color: rgba(255, 255, 255, 0.87); | ||
background-color: #242424; | ||
|
||
font-synthesis: none; | ||
text-rendering: optimizeLegibility; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
} | ||
|
||
a { | ||
font-weight: 500; | ||
color: #646cff; | ||
text-decoration: inherit; | ||
} | ||
a:hover { | ||
color: #535bf2; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
display: flex; | ||
place-items: center; | ||
min-width: 320px; | ||
min-height: 100vh; | ||
} | ||
|
||
@media (prefers-color-scheme: light) { | ||
:root { | ||
color: #213547; | ||
background-color: #ffffff; | ||
} | ||
} |
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,127 @@ | ||
import { LitElement, css, html } from 'lit' | ||
import { customElement, property } from 'lit/decorators.js' | ||
import litLogo from './assets/lit.svg' | ||
import viteLogo from '/vite.svg' | ||
|
||
/** | ||
* An example element. | ||
* | ||
* @slot - This element has a slot | ||
* @csspart button - The button | ||
*/ | ||
@customElement('my-element') | ||
export class MyElement extends LitElement { | ||
/** | ||
* Copy for the read the docs hint. | ||
*/ | ||
@property() | ||
docsHint = 'Click on the Vite and Lit logos to learn more' | ||
|
||
/** | ||
* The number of times the button has been clicked. | ||
*/ | ||
@property({ type: Number }) | ||
count = 0 | ||
|
||
render() { | ||
return html` | ||
<div> | ||
<a href="https://vitejs.dev" target="_blank"> | ||
<img src=${viteLogo} class="logo" alt="Vite logo" /> | ||
</a> | ||
<a href="https://lit.dev" target="_blank"> | ||
<img src=${litLogo} class="logo lit" alt="Lit logo" /> | ||
</a> | ||
</div> | ||
<slot></slot> | ||
<div class="card"> | ||
<button @click=${this._onClick} part="button"> | ||
count is ${this.count} | ||
</button> | ||
</div> | ||
<p class="read-the-docs">${this.docsHint}</p> | ||
` | ||
} | ||
|
||
private _onClick() { | ||
this.count++ | ||
} | ||
|
||
static styles = css` | ||
:host { | ||
max-width: 1280px; | ||
margin: 0 auto; | ||
padding: 2rem; | ||
text-align: center; | ||
} | ||
.logo { | ||
height: 6em; | ||
padding: 1.5em; | ||
will-change: filter; | ||
transition: filter 300ms; | ||
} | ||
.logo:hover { | ||
filter: drop-shadow(0 0 2em #646cffaa); | ||
} | ||
.logo.lit:hover { | ||
filter: drop-shadow(0 0 2em #325cffaa); | ||
} | ||
.card { | ||
padding: 2em; | ||
} | ||
.read-the-docs { | ||
color: #888; | ||
} | ||
::slotted(h1) { | ||
font-size: 3.2em; | ||
line-height: 1.1; | ||
} | ||
a { | ||
font-weight: 500; | ||
color: #646cff; | ||
text-decoration: inherit; | ||
} | ||
a:hover { | ||
color: #535bf2; | ||
} | ||
button { | ||
border-radius: 8px; | ||
border: 1px solid transparent; | ||
padding: 0.6em 1.2em; | ||
font-size: 1em; | ||
font-weight: 500; | ||
font-family: inherit; | ||
background-color: #1a1a1a; | ||
cursor: pointer; | ||
transition: border-color 0.25s; | ||
} | ||
button:hover { | ||
border-color: #646cff; | ||
} | ||
button:focus, | ||
button:focus-visible { | ||
outline: 4px auto -webkit-focus-ring-color; | ||
} | ||
@media (prefers-color-scheme: light) { | ||
a:hover { | ||
color: #747bff; | ||
} | ||
button { | ||
background-color: #f9f9f9; | ||
} | ||
} | ||
` | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'my-element': MyElement | ||
} | ||
} |
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 @@ | ||
/// <reference types="vite/client" /> |
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,24 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2020", | ||
"experimentalDecorators": true, | ||
"useDefineForClassFields": false, | ||
"module": "ESNext", | ||
"lib": ["ES2020", "DOM", "DOM.Iterable"], | ||
"skipLibCheck": true, | ||
|
||
/* Bundler mode */ | ||
"moduleResolution": "bundler", | ||
"allowImportingTsExtensions": true, | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": true, | ||
|
||
/* 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 |
---|---|---|
|
@@ -6,10 +6,11 @@ | |
"asg": "pnpm -F \"@takuma-ru/auto-story-generator\"", | ||
"doc": "pnpm -F \"docs\"", | ||
"d:react": "pnpm -F \"react\"", | ||
"d:next": "pnpm -F \"next\"" | ||
"d:next": "pnpm -F \"next\"", | ||
"d:lit": "pnpm -F \"lit\"" | ||
}, | ||
"author": "takuma-ru <[email protected]> (https://github.com/takuma-ru/)", | ||
"license": "MIT", | ||
"license": "ISC", | ||
"packageManager": "[email protected]", | ||
"engines": { | ||
"npm": "use pnpm please!", | ||
|
Oops, something went wrong.