Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into lab
  • Loading branch information
tonghauhive committed Jan 6, 2025
2 parents 7d4151f + f1f893b commit a17d33e
Show file tree
Hide file tree
Showing 18 changed files with 580 additions and 557 deletions.
26 changes: 19 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -755,16 +755,16 @@ <h2>ComboBox</h2>
<h2>Datepicker</h2>
<form id="datepicker-form">
<sgds-input type="date" hasFeedback required></sgds-input>
<sgds-input type="text" label="Label" hinttext="This is a hint text" name="email" inputclasses=""
<sgds-input required type="text" label="Label" hinttext="This is a hint text" name="email" inputclasses=""
invalidfeedback="test" icon="<svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; fill=&quot;currentColor&quot; class=&quot;bi bi-envelope&quot; viewBox=&quot;0 0 16 16&quot;>
<path d=&quot;M0 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V4Zm2-1a1 1 0 0 0-1 1v.217l7 4.2 7-4.2V4a1 1 0 0 0-1-1H2Zm13 2.383-4.708 2.825L15 11.105V5.383Zm-.034 6.876-5.64-3.471L8 9.583l-1.326-.795-5.64 3.47A1 1 0 0 0 2 13h12a1 1 0 0 0 .966-.741ZM1 11.105l4.708-2.897L1 5.383v5.722Z&quot;/>
</svg>" placeholder="Placeholder" required hasFeedback>
</sgds-input>
<!-- <sgds-datepicker mindate="2024-01-02T12:00:00.000Z"
maxdate="2024-01-30T12:00:00.000Z"></sgds-datepicker> -->
<sgds-button type="submit">Submit</sgds-button>
<sgds-datepicker required mindate="2024-01-02T12:00:00.000Z"
maxdate="2024-01-30T12:00:00.000Z"></sgds-datepicker>
<sgds-button type="submit">Submit TEST DATEPICKER</sgds-button>
</form>
<sgds-datepicker label="Choose a date"></sgds-datepicker>
<sgds-datepicker label="Choose a date" hintText="hint text"></sgds-datepicker>

<sgds-datepicker id="lukhei" label="Birthdate" initialValue='["20/01/2024"]' mindate="2024-01-02T12:00:00.000Z"
maxdate="2024-01-30T12:00:00.000Z">
Expand Down Expand Up @@ -984,6 +984,7 @@ <h2>Badge</h2>
<div class="container">
<h2>Form Validation</h2>
<form id="validation-form">

<sgds-file-upload required multiple hinttext="test" name="fileuploadtest" hasFeedback>
File upload
<sgds-icon slot="icon" size="md" name="placeholder"></sgds-icon>
Expand Down Expand Up @@ -1013,6 +1014,12 @@ <h2>Form Validation</h2>
<sgds-textarea minlength="3" required hasFeedback resize="auto">
<sgds-icon slot="invalidIcon" size="md" name="placeholder"></sgds-icon>
</sgds-textarea>
<!-- <sgds-datepicker required name="datepicker-hi"></sgds-datepicker> -->
<sgds-datepicker id="test-date" required name="datepicker-hi" mindate="2024-01-02T12:00:00.000Z"
maxdate="2024-12-30T12:00:00.000Z"></sgds-datepicker>
<!--<sgds-datepicker required mode="range"></sgds-datepicker>
<sgds-datepicker required mode="range" mindate="2024-01-02T12:00:00.000Z"
maxdate="2024-12-30T12:00:00.000Z"></sgds-datepicker> -->
<sgds-button type="submit" id="submit">Submit</sgds-button>
<sgds-button type="reset" id="submit">Reset</sgds-button>
<sgds-button type="button" id="disableT">Disabled toggle</sgds-button>
Expand Down Expand Up @@ -1718,6 +1725,9 @@ <h2>Dropdown</h2>
<sgds-dropdown-item>
<div href="#">Home</div>
</sgds-dropdown-item>
<sgds-dropdown-item>
<sgds-checkbox>Hello</sgds-checkbox>
</sgds-dropdown-item>
<sgds-dropdown-item active>
<a href="https://google.com" target="_blank"><sgds-icon name="placeholder"></sgds-icon>Option target
blank</a>
Expand Down Expand Up @@ -2071,13 +2081,15 @@ <h2 slot="title">Name of portal/digital service</h2>
qT.disabled = false;
// qT.disabled = false;
});
const daticker = document.querySelector("#test-date")
daticker.initialValue = ["02/01/2024"]
const testF = document.querySelector("#validation-form");

testF.addEventListener("submit", event => {
console.log("submitting");
// event.preventDefault();
event.preventDefault();
const formData = new FormData(event.target);
console.log(formData.get("quant"), "qaunt value");
console.log(formData.get("datepicker-hi"), "datepicker value");
console.log("form report", event.target.reportValidity());
});
const button = document.querySelector("#submit");
Expand Down
52 changes: 26 additions & 26 deletions src/base/button.css
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
:host {
--sgds-btn-font-weight: var(--sgds-font-weight-regular);
--sgds-btn-bg: var(--sgds-primary-bg);
--sgds-btn-hover-bg: var(--sgds-primary-bg-emphasis);
--sgds-btn-border-radius: var(--sgds-border-radius-md);
--btn-font-weight: var(--sgds-font-weight-regular);
--btn-bg: var(--sgds-primary-bg);
--btn-hover-bg: var(--sgds-primary-bg-emphasis);
--btn-border-radius: var(--sgds-border-radius-md);
}

:host([variant="primary"]) {
--sgds-btn-bg: var(--sgds-primary-bg);
--sgds-btn-color: var(--sgds-default-color-on-dark);
--btn-bg: var(--sgds-primary-bg);
--btn-color: var(--sgds-default-color-on-dark);
}

:host([variant="outline"]) {
--sgds-btn-bg: var(--sgds-default-bg-transparent);
--sgds-btn-hover-bg: var(--sgds-primary-bg-translucent);
--sgds-btn-color: var(--sgds-primary-color);
--sgds-btn-border-width: var(--sgds-border-width-1);
--sgds-btn-border-color: var(--sgds-primary-border-color);
--btn-bg: var(--sgds-default-bg-transparent);
--btn-hover-bg: var(--sgds-primary-bg-translucent);
--btn-color: var(--sgds-primary-color);
--btn-border-width: var(--sgds-border-width-1);
--btn-border-color: var(--sgds-primary-border-color);
}

:host([variant="ghost"]) {
--sgds-btn-bg: var(--sgds-default-bg-transparent);
--sgds-btn-hover-bg: var(--sgds-primary-bg-translucent);
--sgds-btn-color: var(--sgds-primary-color);
--btn-bg: var(--sgds-default-bg-transparent);
--btn-hover-bg: var(--sgds-primary-bg-translucent);
--btn-color: var(--sgds-primary-color);
}

:host([variant="danger"]) {
--sgds-btn-bg: var(--sgds-danger-bg);
--sgds-btn-hover-bg: var(--sgds-danger-bg-emphasis);
--sgds-btn-color: var(--sgds-default-color-on-dark);
--btn-bg: var(--sgds-danger-bg);
--btn-hover-bg: var(--sgds-danger-bg-emphasis);
--btn-color: var(--sgds-default-color-on-dark);
}

.btn {
background-color: var(--sgds-btn-bg);
background-color: var(--btn-bg);
border: 1px solid var(--sgds-default-border-color-transparent);
border-radius: var(--sgds-btn-border-radius);
border-radius: var(--btn-border-radius);
color: var(--sgds-default-color-on-dark);
cursor: pointer;
display: inline-flex;
align-items: center;
justify-content: center;
gap: var(--sgds-gap-2-xs);
font-size: var(--sgds-font-size-2);
font-weight: var(--sgds-btn-font-weight);
font-weight: var(--btn-font-weight);
line-height: var(--sgds-line-height-body);
padding: 0px var(--sgds-padding-lg);
min-width: var(--sgds-dimension-96);
Expand All @@ -57,11 +57,11 @@
.btn-primary,
.btn-outline,
.btn-ghost {
color: var(--sgds-btn-color);
color: var(--btn-color);
}

.btn-outline {
border: var(--sgds-btn-border-width) solid var(--sgds-btn-border-color);
border: var(--btn-border-width) solid var(--btn-border-color);
}

@media (prefers-reduced-motion: reduce) {
Expand All @@ -72,12 +72,12 @@

.btn:hover,
.btn.active {
background-color: var(--sgds-btn-hover-bg);
background-color: var(--btn-hover-bg);
}

.btn:focus,
.btn:focus-visible {
background-color: var(--sgds-btn-hover-bg);
background-color: var(--btn-hover-bg);
border-color: transparent;
box-shadow: var(--sgds-box-shadow-focus);
outline: 0;
Expand All @@ -87,7 +87,7 @@
.btn:disabled {
opacity: var(--sgds-opacity-50);
cursor: not-allowed;
color: var(--sgds-btn-color);
color: var(--btn-color);
}

.btn-lg {
Expand All @@ -105,5 +105,5 @@
}

.btn slot::slotted(*) {
color: var(--sgds-btn-color);
color: var(--btn-color);
}
109 changes: 52 additions & 57 deletions src/components/Datepicker/datepicker-calendar.css
Original file line number Diff line number Diff line change
@@ -1,91 +1,86 @@
button {
font-family: inherit;
font-size: inherit;
line-height: inherit;
margin: 0;
}
.datepicker-body {
padding: 0 1.5rem 1.5rem;
.datepicker-body{
color: var(--sgds-form-color-default);
}

table {
border-collapse: collapse;
text-align: center;
}
.sgds.monthpicker,
.sgds.yearpicker {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(4, 3rem);
justify-content: space-between;
align-content: space-between;
padding: 1rem 0 0;
grid-template-columns: repeat(3, 6rem);
grid-template-rows: repeat(4, 2.5rem);
}

button.month,
button.year {
padding: 0;
border: 0;
background-color: transparent;
border-radius: var(--sgds-form-border-radius-sm);
}
button.month.active {
td[data-day].active:not(.selected-ends),
button.month.active:not(.selected-ends),
button.year.active:not(.selected-ends)
{
cursor: pointer;
background-color: var(--datepicker-hover-bg);
background-color: var(--sgds-form-primary-bg-translucent);
border-radius: 0;
}
button.month.active.selected-ends {
background-color: var(--datepicker-selected-date-bg);
color: var(--datepicker-selected-date-color);
}
button.month:hover:not(.active) {
td[data-day]:hover:not(.disabled):not(.selected-ends):not(.active),
button.month:hover:not(.active),
button.year:hover:not(.active) {
cursor: pointer;
background-color: var(--datepicker-hover-bg);
background-color: var(--sgds-form-bg-translucent);
}
button.month:focus {
outline: var(--datepicker-theme-color) auto 2px;
z-index: 100;
td[data-day]:focus,
button.month:focus,
button.year:focus {
box-shadow: var(--sgds-box-shadow-focus);
outline: unset;
}
button.year.active {
cursor: pointer;
background-color: var(--datepicker-hover-bg);
}
button.year.active.selected-ends {
background-color: var(--datepicker-selected-date-bg);
color: var(--datepicker-selected-date-color);
}
button.year:hover:not(.active) {
cursor: pointer;
background-color: var(--datepicker-hover-bg);
}
button.year:focus {
outline: var(--datepicker-theme-color) auto 2px;
z-index: 100;
background-color: var(--sgds-form-primary-bg-translucent);
}
td {
width: 3rem;
height: 3rem;

td, th {
width: var(--sgds-form-width-md);
height: var(--sgds-form-height-lg);
padding: 0;
border-radius: var(--sgds-form-border-radius-sm);
}
td[data-day] {
cursor: pointer;
}
td[data-day]:hover:not(.disabled):not(.selected-ends) {
cursor: pointer;
background-color: var(--datepicker-hover-bg);
}
td[data-day].active {
cursor: pointer;
background-color: var(--datepicker-hover-bg);
}
td[data-day].active.selected-ends {
background-color: var(--datepicker-selected-date-bg);
color: var(--datepicker-selected-date-color);
}
td[data-day]:focus {
outline: var(--datepicker-theme-color) auto 2px;

td[data-day].active.selected-ends,
button.month.active.selected-ends ,
button.year.active.selected-ends {
background-color: var(--sgds-form-primary-bg);
color: var(--sgds-form-color-on-dark);
}
td[data-day].disabled {
color: var(--sgds-gray-400);
opacity: var(--sgds-opacity-50);
cursor: not-allowed;
}
.today {
color: var(--datepicker-theme-color);
.today{
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top: 4px;
}
.today::after{
background-color: var(--sgds-form-primary-bg);
content: ".";
line-height: 4px;
-webkit-mask-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4" viewBox="0 0 4 4" fill="none"><circle cx="2" cy="2" r="2" fill="%235A42C0"/></svg>');
mask-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4" viewBox="0 0 4 4" fill="none"><circle cx="2" cy="2" r="2" fill="%235A42C0"/></svg>');
-webkit-mask-repeat: no-repeat;
mask-repeat: no-repeat;
-webkit-mask-position: center;
mask-position: center;

}
7 changes: 1 addition & 6 deletions src/components/Datepicker/datepicker-calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ export class DatepickerCalendar extends SgdsElement {

private _onClickDay(event: MouseEvent | KeyboardEvent) {
const { day, date } = (event.composedPath()[0] as HTMLTableCellElement).dataset;

const displayDateClone = new Date(this.displayDate);
displayDateClone.setDate(parseInt(day));
/** update new focused date for mouse click */
Expand Down Expand Up @@ -392,11 +391,7 @@ export class DatepickerCalendar extends SgdsElement {
<tr>
${DatepickerCalendar.DAY_LABELS.map(
(label: string, index: number) =>
html`
<th key=${index} abbr=${label} scope="col">
<small>${label.slice(0, 3)}</small>
</th>
`
html` <th key=${index} abbr=${label} scope="col">${label.slice(0, 3)}</th> `
)}
</tr>
</thead>
Expand Down
29 changes: 0 additions & 29 deletions src/components/Datepicker/datepicker-header.css
Original file line number Diff line number Diff line change
@@ -1,32 +1,3 @@
.datepicker-header {
padding: 1.5rem 1.5rem 0;
border: none;
color: var(--datepicker-theme-color);
display: flex;
text-align: center;
justify-content: space-between;
align-items: center;
line-height: 28px;
}
.datepicker-header button {
cursor: pointer;
background-color: transparent;
color: var(--datepicker-theme-color);
border: none;
font-weight: bold;
font-size: 14px;
line-height: var(--sgds-line-height-lg);
}
.datepicker-header button:focus {
outline: var(--datepicker-theme-color) auto 2px;
}
.datepicker-header button.disabled {
cursor: not-allowed;
}
.datepicker-header button:hover:not(.disabled) {
background-color: var(--datepicker-hover-bg);
}
.datepicker-header svg {
font-size: 10rem;
vertical-align: middle;
}
Loading

0 comments on commit a17d33e

Please sign in to comment.