Skip to content

Commit

Permalink
simplify header + improve styling
Browse files Browse the repository at this point in the history
  • Loading branch information
mucsi96 committed May 2, 2024
1 parent fc01c79 commit ddff9f2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/Docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ body {
background-color: var(--bt-background-color);
color: var(--bt-text-color);
font-family: var(--bt-font-family);
margin: 0;
}
```

Expand Down
7 changes: 5 additions & 2 deletions src/Header/Header.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import { BTHeaderProps } from './Header';
const meta: Meta<BTHeaderProps> = {
title: 'BTHeader',
render: () =>
html`<header is="bt-header" title="Header title">
<h6 is="bt-heading">child text</h6>
html`<header is="bt-header">
<nav>
<a href="/"><h1 is="bt-heading">App</h1></a>
<button is="bt-button">Sign in</button>
</nav>
</header>
<main is="bt-main">
<h1 is="bt-heading">main text</h1>
Expand Down
19 changes: 3 additions & 16 deletions src/Header/Header.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { css, html } from 'lit';
import { customElement, htmlToString } from '../utils';
import { css } from 'lit';
import { customElement } from '../utils';

export type BTHeaderProps = {
title?: string;
Expand Down Expand Up @@ -29,17 +29,4 @@ export type BTHeaderProps = {
}
`,
})
export class BTHeader extends HTMLElement {
template = document.createElement('template');

constructor() {
super();
this.template.innerHTML = htmlToString(html`
<h1 is="bt-heading">${this.title}</h1>
`);
}

connectedCallback() {
this.firstElementChild?.prepend(this.template.content.cloneNode(true));
}
}
export class BTHeader extends HTMLElement {}
14 changes: 12 additions & 2 deletions src/Heading/Heading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@ export type BTHeadingProps = {};
name: 'bt-heading',
extends: 'h1',
styles: css`
[is="bt-heading"] {
[is='bt-heading'] {
display: block;
color: var(--bt-strong-text-color);
color: var(--heading-color, var(--bt-strong-text-color));
transition: color 0.3s;
margin: unset;
a:has(&) {
color: var(--bt-strong-text-color);
text-decoration: none;
}
a:has(&):hover {
--heading-color: var(--bt-text-color);
}
}
`,
})
Expand Down

0 comments on commit ddff9f2

Please sign in to comment.