Skip to content

Commit

Permalink
refactor(BaseInput): only use has for supported browsers, otherwise u…
Browse files Browse the repository at this point in the history
…se class for wrapper
  • Loading branch information
YossiSaadi committed Apr 17, 2024
1 parent b5ecf9f commit ec1ceda
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 29 deletions.
102 changes: 77 additions & 25 deletions packages/core/src/components/BaseInput/BaseInput.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,49 +43,101 @@
border-color: var(--primary-text-color);
}

&:has(.input:active, .input:focus) {
border-color: var(--primary-color);
@supports selector(:has(*)) {
&:has(.input:active, .input:focus) {
border-color: var(--primary-color);
}

&:has(.input:read-only) {
background-color: var(--allgrey-background-color);
border: none;

.input {
background-color: var(--allgrey-background-color);
}
}

&:has(.input:disabled) {
cursor: not-allowed;
user-select: none;
border: none;
pointer-events: none;
background-color: var(--disabled-background-color);
}
}

// TODO in next major remove withReadOnlyStyle, should only be determined by read-only existence on input
&:has(.input:read-only).withReadOnlyStyle {
background-color: var(--allgrey-background-color);
border: none;
@supports not selector(:has(*)) {
&:focus-within {
border-color: var(--primary-color);
}

.input {
&.readOnly {
background-color: var(--allgrey-background-color);
border: none;

.input {
background-color: var(--allgrey-background-color);
}
}
}

&:has(.input:disabled) {
cursor: not-allowed;
user-select: none;
border: none;
pointer-events: none;
background-color: var(--disabled-background-color);
&.disabled {
cursor: not-allowed;
user-select: none;
border: none;
pointer-events: none;
background-color: var(--disabled-background-color);
}
}

&.success {
border-color: var(--positive-color);

&:hover {
@supports selector(:has(*)) {
&.success {
border-color: var(--positive-color);

&:hover {
border-color: var(--positive-color);
}

&:has(.input:active, .input:focus) {
border-color: var(--positive-color);
}
}

&:has(.input:active, .input:focus) {
border-color: var(--positive-color);
&:has(.input[aria-invalid="true"]) {
border-color: var(--negative-color);

&:hover {
border-color: var(--negative-color);
}

&:has(.input:active, .input:focus) {
border-color: var(--negative-color);
}
}
}

&:has(.input[aria-invalid="true"]) {
border-color: var(--negative-color);
@supports not selector(:has(*)) {
&.success {
border-color: var(--positive-color);

&:hover {
border-color: var(--positive-color);
}

&:hover {
border-color: var(--negative-color);
&:focus-within {
border-color: var(--positive-color);
}
}

&:has(.input:active, .input:focus) {
&.error {
border-color: var(--negative-color);

&:hover {
border-color: var(--negative-color);
}

&:focus-within {
border-color: var(--negative-color);
}
}
}

Expand Down
7 changes: 4 additions & 3 deletions packages/core/src/components/BaseInput/BaseInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const BaseInput: BaseInputComponent = forwardRef(
size = "medium",
leftRender,
rightRender,
withReadOnlyStyle,
success,
error,
wrapperRole,
Expand All @@ -25,8 +24,10 @@ const BaseInput: BaseInputComponent = forwardRef(
styles.wrapper,
{
[styles.rightThinnerPadding]: !rightRender,
[styles.withReadOnlyStyle]: withReadOnlyStyle,
[styles.success]: success
[styles.error]: error,
[styles.success]: success,
[styles.readOnly]: props.readOnly,
[styles.disabled]: props.disabled
},
getStyle(styles, size),
wrapperClassName
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/components/BaseInput/BaseInput.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export interface BaseInputProps extends BaseInputNativeInputProps, VibeComponent
size?: InputSize;
leftRender?: Renderer;
rightRender?: Renderer;
withReadOnlyStyle?: boolean;
success?: boolean;
error?: boolean;
wrapperRole?: AriaRole;
Expand Down

0 comments on commit ec1ceda

Please sign in to comment.