-
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.
Merge pull request #70 from xsolla/PAYMENTS-18588
feat(PAYMENTS-18588): rework select and checkbox component
- Loading branch information
Showing
12 changed files
with
321 additions
and
72 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions
63
src/features/headless-checkout/web-components/checkbox/checkbox.component.scss
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,5 +1,68 @@ | ||
@use 'src/styles/mixins/typo.mixin' as typo; | ||
|
||
psdk-checkbox { | ||
$checkbox-size: 18px; | ||
$checkbox-img-size: 14px; | ||
$checkbox-offset: 1px; | ||
@include typo.psdk-typo; | ||
|
||
.checkbox { | ||
position: relative; | ||
display: flex; | ||
|
||
.wrapper { | ||
display: flex; | ||
flex-direction: column; | ||
margin-left: 8px; | ||
} | ||
|
||
&-dummy { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
display: block; | ||
width: $checkbox-size; | ||
height: $checkbox-size; | ||
border-color: var(--psdk-checkbox-unchecked-bg); | ||
border-radius: 2px; | ||
background: var(--psdk-checkbox-unchecked-bg); | ||
|
||
img { | ||
position: absolute; | ||
display: none; | ||
width: $checkbox-img-size; | ||
height: $checkbox-img-size; | ||
inset: $checkbox-offset + 1 $checkbox-offset $checkbox-offset - 1 | ||
$checkbox-offset + 1; | ||
} | ||
} | ||
} | ||
|
||
input { | ||
z-index: 1; | ||
display: inline-block; | ||
width: $checkbox-size; | ||
height: $checkbox-size; | ||
margin: 0; | ||
border: 1px solid transparent; | ||
background: transparent; | ||
cursor: pointer; | ||
appearance: none; | ||
} | ||
|
||
input, | ||
input:checked { | ||
border: 1px solid transparent; | ||
background: transparent; | ||
appearance: none; | ||
} | ||
|
||
input:checked + .checkbox-dummy { | ||
border-color: var(--psdk-checkbox-checked-bg); | ||
background: var(--psdk-checkbox-checked-bg); | ||
|
||
img { | ||
display: block; | ||
} | ||
} | ||
} |
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
17 changes: 12 additions & 5 deletions
17
src/features/headless-checkout/web-components/checkbox/checkbox.template.ts
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,22 +1,29 @@ | ||
import { XpsBoolean } from '../../../../core/xps-boolean.enum'; | ||
import { CheckboxComponentConfig } from './checkbox-component-config.interface'; | ||
import check from '../../../../assets/icons/check.svg'; | ||
|
||
export const getCheckboxComponentTemplate = ( | ||
config: CheckboxComponentConfig | ||
config: CheckboxComponentConfig, | ||
): string => { | ||
const isChecked = config.initValue === XpsBoolean.true; | ||
const placeholder = config.placeholder; | ||
const error = config.error; | ||
|
||
return ` | ||
<label for='${config.name}' class='wrapper'> | ||
<div class='checkbox'> | ||
<input | ||
class='checkbox' | ||
type='checkbox' | ||
id='${config.name}' | ||
name='${config.name}' | ||
${isChecked ? 'checked' : ''} | ||
/> | ||
${placeholder ? `<span class='label'>${placeholder}</span>` : ''} | ||
</label> | ||
<div class='checkbox-dummy'> | ||
${isChecked ? `<img src='${check}' alt='checkbox'>` : ''} | ||
</div> | ||
<div class='wrapper'> | ||
${placeholder ? `<span class='label'>${placeholder}</span>` : ''} | ||
${error ? `<span class='field-error'>${error}</span>` : ''} | ||
</div> | ||
</div> | ||
`; | ||
}; |
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
6 changes: 6 additions & 0 deletions
6
src/features/headless-checkout/web-components/select/select-keys.enum.ts
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,6 @@ | ||
export enum SelectKeys { | ||
enter = 'enter', | ||
space = 'space', | ||
arrowUp = 'arrowup', | ||
arrowDown = 'arrowdown', | ||
} |
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.