-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add scaffolding for UI components, and initial component (#62)
* feat: initial commit of UI, basic base CSS, and sd-field * fix: spacing of body and field * refactor: switch to fix width * refactor: switch to actual CSS files * test: fix tests with ESM / CSS import * fix: missing CSS variables for coloring * refactor: rename field class to align with existing HTML elements * chore: fix linting, and include js, cjs, and mjs files --------- Co-authored-by: Richard Herman <[email protected]>
- Loading branch information
Showing
12 changed files
with
222 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,65 @@ | ||
import { LitElement, css, html, type HTMLTemplateResult } from "lit"; | ||
import { customElement, property } from "lit/decorators.js"; | ||
|
||
/** | ||
* Field that identifies an input, or group of inputs. | ||
*/ | ||
@customElement("sd-field") | ||
export class SDFieldElement extends LitElement { | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public static styles = [ | ||
css` | ||
.sd-field { | ||
align-items: baseline; | ||
column-gap: 10px; | ||
display: grid; | ||
grid-template-columns: 93px 262px; | ||
} | ||
`, | ||
]; | ||
|
||
/** | ||
* Label to show for the field. | ||
*/ | ||
@property() | ||
accessor label: string | undefined = undefined; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public render(): HTMLTemplateResult { | ||
return html` | ||
<div class="sd-field"> | ||
<div class="sd-field-label"> | ||
<label @click=${this.#focusFirstElement}>${this.label ? this.label + ":" : undefined}</label> | ||
</div> | ||
<div class="sd-field-input"> | ||
<slot></slot> | ||
</div> | ||
</div> | ||
`; | ||
} | ||
|
||
/** | ||
* Focuses the first element, that can have focus, within the field. | ||
*/ | ||
#focusFirstElement(): void { | ||
for (const el of this.querySelectorAll("*")) { | ||
if ("focus" in el && typeof el.focus === "function") { | ||
el.focus(); | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
/** | ||
* Field that identifies an input, or group of inputs. | ||
*/ | ||
"sd-field": SDFieldElement; | ||
} | ||
} |
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 @@ | ||
import "./field"; |
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 @@ | ||
declare module "*.css"; |
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,37 @@ | ||
:root { | ||
--sd-background-color: #2d2d2d; | ||
--sd-color-content-primary: #d8d8d8; | ||
--sd-color-content-secondary: #969696; | ||
--sd-font-size: 12px; | ||
--sd-line-height: calc(var(--sd-font-size) * 1.333); | ||
--sd-scrollbar-track-color: #262626; | ||
--sd-scrollbar-thumb-color: #666666; | ||
} | ||
|
||
body { | ||
background-color: var(--sd-background-color); | ||
color: var(--sd-color-content-primary); | ||
font-size: var(--sd-font-size); | ||
font-family: | ||
System, | ||
"Segoe UI", | ||
Arial, | ||
Roboto, | ||
Helvetica sans-serif; | ||
line-height: var(--sd-line-height); | ||
margin: 8px 8px 8px 0px; | ||
text-rendering: optimizeLegibility; | ||
} | ||
|
||
::-webkit-scrollbar { | ||
width: 4px; | ||
} | ||
|
||
::-webkit-scrollbar-track { | ||
background-color: var(--sd-scrollbar-track-color); | ||
} | ||
|
||
::-webkit-scrollbar-thumb { | ||
background-color: var(--sd-scrollbar-thumb-color); | ||
border-radius: 2px; | ||
} |
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,12 @@ | ||
/** | ||
* An empty Jest transform, allowing for specific files to be omitted, for example CSS files. | ||
*/ | ||
module.exports = { | ||
/** | ||
* Processes the file, transforming it to a readable state... of no code. | ||
* @returns An empty set of code, without a map, that mimics a transformed file. | ||
*/ | ||
process: () => { | ||
return { code: "" }; | ||
}, | ||
}; |