-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
158 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.colors-list { | ||
margin: 0; | ||
padding: 0; | ||
list-style-type: none; | ||
} | ||
|
||
.color-radio { | ||
display: none; | ||
} | ||
|
||
.color-item { | ||
margin: 0 0 4px; | ||
} | ||
|
||
.color-label { | ||
display: flex; | ||
padding: 6px 8px; | ||
border-radius: 6px; | ||
display: flex; | ||
line-height: 20px; | ||
} | ||
|
||
.color-flag { | ||
display: inline-block; | ||
width: 24px; | ||
height: 18px; | ||
margin-block-start: 1px; | ||
margin-inline-end: 12px; | ||
outline: 1px solid rgba(255,255,255,0.5); | ||
} | ||
|
||
input:checked + .color-label { | ||
background-color: #94a3b8; | ||
} | ||
|
||
input:checked + .color-label .color-flag { | ||
outline: none; | ||
} |
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,53 @@ | ||
import { querySelectorSafe } from "../shared/utils"; | ||
|
||
import "./ColorSelector.css"; | ||
|
||
type Color = { | ||
name: string; | ||
code: string; | ||
} | ||
|
||
const colors: Color[] = [ | ||
{ | ||
name: "Olive", | ||
code: "#5f6a5e", | ||
}, | ||
{ | ||
name: "Stone", | ||
code: "#a8a29e", | ||
}, | ||
{ | ||
name: "Silver", | ||
code: "#f1f5f9", | ||
}, | ||
{ | ||
name: "Sand", | ||
code: "#eed9c4", | ||
}, | ||
{ | ||
name: "Rose", | ||
code: "#ecc5c0", | ||
}, | ||
]; | ||
|
||
export class ColorSelector { | ||
constructor( | ||
private container: HTMLElement, | ||
private template: HTMLTemplateElement, | ||
) { } | ||
|
||
initialize() { | ||
colors.forEach(color => { | ||
const clone = this.template.content.cloneNode(true) as HTMLLIElement; | ||
const id = color.code.replace("#", ""); | ||
|
||
querySelectorSafe<HTMLInputElement>("input", clone).value = color.code; | ||
querySelectorSafe<HTMLInputElement>("input", clone).id = id; | ||
querySelectorSafe<HTMLLabelElement>("label", clone).setAttribute("for", id); | ||
querySelectorSafe<HTMLSpanElement>(".color-name", clone).innerText = color.name; | ||
querySelectorSafe<HTMLSpanElement>(".color-flag", clone).style.backgroundColor = color.code; | ||
|
||
this.container.appendChild(clone); | ||
}); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { ColorSelector } from "./ColorSelector"; | ||
export { CountrySelector } from "./CountrySelector"; | ||
export { Settings } from "./Settings"; | ||
export { Settings, type SettingsData } from "./Settings"; |
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