-
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.
Merge pull request #76 from etchteam/feature/etch-545-better-spacing-…
…docs Feature/etch 545 better spacing docs
- Loading branch information
Showing
24 changed files
with
335 additions
and
30 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
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
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
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
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
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
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,97 @@ | ||
import { LitElement, html, css } from 'lit'; | ||
import { customElement, property } from 'lit/decorators.js'; | ||
|
||
import { JSXCustomElement } from '../../types/jsx-custom-element'; | ||
|
||
export interface SpacingAttributes { | ||
size: string; | ||
} | ||
|
||
@customElement('docs-spacing') | ||
export class TokenTable extends LitElement { | ||
@property({ reflect: true }) size: string = 'md'; | ||
@property({ reflect: true }) direction: 'top' | 'bottom' = 'bottom'; | ||
@property({ reflect: true }) alignment: 'center' | 'left' = 'center'; | ||
|
||
static readonly styles = css` | ||
:host { | ||
display: block; | ||
color: var(--diamond-color-red-100); | ||
font-size: var(--diamond-font-size-xs); | ||
height: 0; | ||
position: relative; | ||
} | ||
:host([direction='top']) .docs-spacing__content { | ||
transform: translateY(-100%); | ||
} | ||
:host([alignment='left']) .docs-spacing__content { | ||
justify-content: flex-start; | ||
padding-left: var(--diamond-spacing-md); | ||
} | ||
.docs-spacing__content { | ||
align-items: center; | ||
display: flex; | ||
gap: var(--diamond-spacing-xs); | ||
height: var(--docs-spacing-height); | ||
justify-content: center; | ||
padding-left: var(--diamond-spacing-md); | ||
} | ||
.docs-spacing__border { | ||
border-bottom: 1px solid var(--diamond-color-red-100); | ||
border-top: 1px solid var(--diamond-color-red-100); | ||
height: 100%; | ||
position: relative; | ||
width: 7px; | ||
} | ||
.docs-spacing__border::before { | ||
background-color: var(--diamond-color-red-100); | ||
content: ''; | ||
display: block; | ||
height: 100%; | ||
left: 50%; | ||
position: absolute; | ||
width: 1px; | ||
} | ||
.docs-spacing__text { | ||
max-width: 0; | ||
white-space: nowrap; | ||
width: 0; | ||
} | ||
`; | ||
|
||
render() { | ||
const { size } = this; | ||
|
||
return html` | ||
<style> | ||
:host { | ||
--docs-spacing-height: var(--diamond-spacing-${size}); | ||
} | ||
</style> | ||
<div class="docs-spacing__content"> | ||
<div class="docs-spacing__border"></div> | ||
<div class="docs-spacing__text">${size}</div> | ||
</div> | ||
`; | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'docs-spacing': SpacingAttributes; | ||
} | ||
} | ||
|
||
declare module 'react' { | ||
namespace JSX { | ||
interface IntrinsicElements { | ||
'docs-spacing': JSXCustomElement<SpacingAttributes>; | ||
} | ||
} | ||
} |
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,101 @@ | ||
import { LitElement, html, css } from 'lit'; | ||
import { customElement, property } from 'lit/decorators.js'; | ||
|
||
import { JSXCustomElement } from '../../types/jsx-custom-element'; | ||
|
||
export interface TokenTableAttributes { | ||
code: string; | ||
} | ||
|
||
@customElement('docs-token-table') | ||
export class TokenTable extends LitElement { | ||
@property({ reflect: true }) code: string; | ||
|
||
static readonly styles = css` | ||
:host { | ||
display: block; | ||
} | ||
table { | ||
border: var(--diamond-border); | ||
border-collapse: collapse; | ||
margin-block: var(--diamond-spacing-lg); | ||
text-align: left; | ||
width: 100%; | ||
} | ||
th, | ||
td { | ||
border: var(--diamond-border); | ||
font-size: var(--diamond-font-size-sm); | ||
padding: var(--diamond-spacing-sm); | ||
} | ||
th { | ||
background-color: var(--diamond-color-grey-50); | ||
} | ||
code { | ||
background-color: var(--diamond-color-grey-50); | ||
border: var(--diamond-border); | ||
border-radius: var(--diamond-radius-sm); | ||
color: var(--diamond-color-grey-700); | ||
font-size: var(--diamond-font-size-sm); | ||
line-height: 1; | ||
padding: var(--diamond-spacing-xs) var(--diamond-spacing-sm); | ||
white-space: nowrap; | ||
} | ||
`; | ||
|
||
render() { | ||
const { code } = this; | ||
|
||
// Find all the tokens in the code | ||
const splitTokens = code.split(';'); | ||
const parsedTokens = splitTokens | ||
.map((token) => /--diamond-([a-z]+)-([a-z-]+): (.+)/.exec(token)) | ||
.filter(Boolean) | ||
.map((token) => ({ | ||
group: token?.[1], | ||
name: token?.[2], | ||
value: token?.[3], | ||
})); | ||
|
||
return html` | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Token</th> | ||
<th>Default value</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
${parsedTokens.map( | ||
(token) => html` | ||
<tr> | ||
<td>${token?.name}</td> | ||
<td><code>--diamond-${token?.group}-${token?.name}</code></td> | ||
<td>${token?.value}</td> | ||
</tr> | ||
`, | ||
)} | ||
</tbody> | ||
</table> | ||
`; | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'docs-token-table': TokenTableAttributes; | ||
} | ||
} | ||
|
||
declare module 'react' { | ||
namespace JSX { | ||
interface IntrinsicElements { | ||
'docs-token-table': JSXCustomElement<TokenTableAttributes>; | ||
} | ||
} | ||
} |
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
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
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
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
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
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
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
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
Oops, something went wrong.