Skip to content

Commit

Permalink
feat(page): add page component
Browse files Browse the repository at this point in the history
Page - the root element
our first component!
  • Loading branch information
lingbopro committed Dec 7, 2024
1 parent 6363084 commit 670fa4b
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './page';
1 change: 1 addition & 0 deletions src/components/page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './page/page';
6 changes: 6 additions & 0 deletions src/components/page/page.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:host {
display: flow-root;
color: rgb(var(--mm-color-on-background));
background-color: rgb(var(--mm-color-background));
font-family: Roboto, system-ui;
}
1 change: 1 addition & 0 deletions src/components/page/page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<slot></slot>
40 changes: 40 additions & 0 deletions src/components/page/page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { useElement } from '../../core/element';
import { defaultTheme, generateCSSKeys, overrideColorKeys } from '../../utils/theme';
import template from './page.html';
import style from './page.css';

const name = 'mm-page';
const props = {
theme: 'auto' as 'auto' | 'light' | 'dark',
};

const themeStyle = /* css */ `
:host {
${generateCSSKeys(defaultTheme)}
}
@media (prefers-color-scheme: light) {
:host {
${overrideColorKeys.light}
}
}
@media (prefers-color-scheme: dark) {
:host {
${overrideColorKeys.dark}
}
}
:host([theme="light"]) {
${overrideColorKeys.light}
}
:host([theme="dark"]) {
${overrideColorKeys.dark}
}`;

export class Page extends useElement({
template,
style: [style, themeStyle],
props,
}) {
declare theme: typeof props.theme;
}

Page.define(name);
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * as components from './components/index';

0 comments on commit 670fa4b

Please sign in to comment.