Skip to content

Commit

Permalink
fix: proper header styling
Browse files Browse the repository at this point in the history
  • Loading branch information
favna committed Feb 10, 2024
1 parent 117122c commit d2ccc26
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
9 changes: 9 additions & 0 deletions packages/core/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,15 @@ <h3 class="title">Inline fields with a thumbnail</h3>
</discord-embed>
</discord-message>
</discord-messages>

<h3 class="title">Headers</h3>
<discord-messages>
<discord-message profile="favna">
<discord-header level="1">This is a header 1</discord-header>
<discord-header level="2">This is a header 2</discord-header>
<discord-header level="3">This is a header 3</discord-header>
</discord-message>
</discord-messages>
</main>
</div>
</body>
Expand Down
17 changes: 10 additions & 7 deletions packages/core/src/components/discord-header/DiscordHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@ import { customElement, property } from 'lit/decorators.js';
@customElement('discord-header')
export class DiscordHeader extends LitElement {
public static override styles = css`
:host {
:host > * {
margin: 16px 0 8px;
font-weight: 700;
line-height: 1.375em;
}
:host([level='1']) {
:host([level='1']) > h1 {
font-size: 1.5rem;
}
:host([level='2']) {
:host([level='2']) > h2 {
font-size: 1.25rem;
}
:host([level='3']) {
:host([level='3']) > h3 {
font-size: 1rem;
}
:host([level='1']):first-child(),
:host([level='2']):first-child() {
:host([level='1']):first-child() > h1,
:host([level='2']):first-child() > h2 {
margin-top: 8px;
}
:host([level='3']):first-child() {
:host([level='3']):first-child() > h3 {
margin-top: 4px;
}
`;
Expand Down Expand Up @@ -58,6 +58,9 @@ export class DiscordHeader extends LitElement {
case 3: {
return html`<h3><slot></slot></h3>`;
}
default: {
return html`<slot></slot>`;
}
}
}
}
Expand Down

0 comments on commit d2ccc26

Please sign in to comment.