Skip to content

Commit

Permalink
refactor: update input components css to use bem styles and mixins
Browse files Browse the repository at this point in the history
Refs: #7178
  • Loading branch information
Makko74 committed Dec 10, 2024
1 parent f45ce05 commit 700397a
Show file tree
Hide file tree
Showing 57 changed files with 1,435 additions and 928 deletions.
25 changes: 25 additions & 0 deletions packages/components/src/components/form-field.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@layer kol-component {
.kol-form-field {
$root: &;

display: grid;

&--disabled {
opacity: 0.5;
}

&--required {
#{$root}__label-text {
&::after {
content: '*';
}
}

#{$root}__tooltip {
.span-label::after {
content: '*';
}
}
}
}
}
43 changes: 0 additions & 43 deletions packages/components/src/components/input-checkbox/button.scss

This file was deleted.

29 changes: 0 additions & 29 deletions packages/components/src/components/input-checkbox/checkbox.scss

This file was deleted.

86 changes: 0 additions & 86 deletions packages/components/src/components/input-checkbox/common.scss

This file was deleted.

25 changes: 15 additions & 10 deletions packages/components/src/components/input-checkbox/shadow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ export class KolInputCheckbox implements InputCheckboxAPI, FocusableElement {
private getFormFieldProps(): FormFieldStateWrapperProps {
return {
state: this.state,
class: clsx('kol-input-checkbox', 'checkbox', this.state._variant, {
'hide-label': !!this.state._hideLabel,
checked: this.state._checked,
indeterminate: this.state._indeterminate,
class: clsx('kol-input-checkbox', {
[`kol-input-checkbox--checked`]: this.state._checked,
[`kol-input-checkbox--indeterminate`]: this.state._indeterminate,
[`kol-input-checkbox--variant-${this.state._variant || 'default'}`]: true,
[`kol-input-checkbox--label-align-${this.state._labelAlign || 'right'}`]: true,
}),
tooltipAlign: this._tooltipAlign,
'data-label-align': this.state._labelAlign || 'right',
'data-role': this.state._variant === 'button' ? 'button' : undefined,
alert: this.showAsAlert(),
reverseLabelInput: this.state._labelAlign === 'right',
Expand All @@ -95,12 +95,11 @@ export class KolInputCheckbox implements InputCheckboxAPI, FocusableElement {

private getInputProps(): InputStateWrapperProps {
return {
class: clsx('checkbox-input-element', {
class: clsx('kol-input-container__checkbox-input-element', {
'visually-hidden': this.state._variant === 'button',
}),
ref: this.catchRef,
type: 'checkbox',
slot: 'input',
state: this.state,
...this.controller.onFacade,
onInput: this.onInput,
Expand All @@ -125,7 +124,7 @@ export class KolInputCheckbox implements InputCheckboxAPI, FocusableElement {

private getIconProps() {
return {
class: 'icon',
class: 'kol-input-container__checkbox-icon',
icons: this.getIcon(),
label: '',
};
Expand All @@ -134,8 +133,14 @@ export class KolInputCheckbox implements InputCheckboxAPI, FocusableElement {
public render(): JSX.Element {
return (
<KolFormFieldStateWrapperFc {...this.getFormFieldProps()}>
<div class="input">
<label class="checkbox-container">
<div
class={clsx('kol-input-container', {
[`kol-input-container--checked`]: this.state._checked,
[`kol-input-container--indeterminate`]: this.state._indeterminate,
[`kol-input-container--variant-${this.state._variant || 'default'}`]: true,
})}
>
<label class="kol-input-container__checkbox-container">
<KolIconFc {...this.getIconProps()} />
<KolInputStateWrapperFc {...this.getInputProps()} />
</label>
Expand Down
Loading

0 comments on commit 700397a

Please sign in to comment.