Files
Amanda Johnston ac102cf52a feat(input): add styles for clear action to ionic theme (#29337)
Issue number: Internal

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

For the `ionic` theme: Adjusted the size of the clear button to match
design specs, and updated the behavior so the button additionally only
shows if the native input *or* any other actions within the `ion-input`
are focused. (See code comments for details.)

The actual icon used has not been modified. The ticket says to "use the
material design clear icon as the reference icon for this feature," and
we've already added a feature allowing the icon to be customized at the
app level. Let me know if the intention was to use a different default
icon with the `ionic` theme.

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!--
  If this introduces a breaking change:
1. Describe the impact and migration path for existing applications
below.
  2. Update the BREAKING.md file with the breaking change.
3. Add "BREAKING CHANGE: [...]" to the commit description when merging.
See
https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer
for more information.
-->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->

---------

Co-authored-by: ionitron <hi@ionicframework.com>
2024-04-16 12:42:35 -05:00

140 lines
3.7 KiB
SCSS

@use "../../foundations/ionic.vars.scss" as tokens;
@import "./input";
@import "./input.ionic.vars";
@import "./input.ionic.outline.scss";
// Ionic Input
// --------------------------------------------------
:host {
--border-width: #{$ionic-border-size-small};
--border-color: #{$ionic-color-neutral-300};
--highlight-color-valid: #{$ionic-color-success-400};
--highlight-color-invalid: #{$ionic-color-error-400};
--text-color-invalid: #{$ionic-color-error-600};
}
// Ionic Input Sizes
// --------------------------------------------------
:host(.input-size-large) .native-wrapper {
min-height: 48px;
}
// Input Clear Button
// ----------------------------------------------------------------
.input-clear-icon {
width: 16px;
height: 16px;
color: #{$ionic-color-neutral-500};
}
.input-clear-icon.ion-focused {
border-radius: #{$ionic-border-radius-rounded-small};
outline: #{$ionic-border-size-medium} solid #{$ionic-color-primary-100};
opacity: 1;
}
.input-clear-icon ion-icon {
width: 100%;
height: 100%;
}
/**
* The clear button should be visible if the native input
* OR any other interactive elements in the component (the
* clear button, slotted buttons, etc.) are focused. If we
* only looked at the native input, tabbing to the clear
* button would immediately hide it.
*
* Note that the clear button also requires the native input
* to have any value, but this is not specific to the ionic
* theme, so it is handled elsewhere.
*/
:host(:not(:focus-within)) .input-clear-icon {
display: none;
}
// Ionic Input Shapes
// --------------------------------------------------
:host(.input-shape-round) {
--border-radius: #{$ionic-border-radius-rounded-full};
}
// Input Bottom Content
// ----------------------------------------------------------------
.input-bottom {
@include padding-horizontal(0, 0);
// TODO(FW-6112): Update it to `$ionic-font-weight-medium` when it's available
font-weight: var(--ionic-font-weight-medium, 500);
}
// Input Hint Text
// ----------------------------------------------------------------
.input-bottom .helper-text {
color: tokens.$ionic-color-neutral-600;
}
:host(.has-focus.ion-valid) .helper-text {
color: #{tokens.$ionic-color-success-800};
}
:host(.ion-touched.ion-invalid) .error-text {
color: var(--text-color-invalid);
}
// Input Hover
// ----------------------------------------------------------------
@media (any-hover: hover) {
:host(:hover) {
--border-color: #{tokens.$ionic-color-neutral-600};
}
}
// Input - Disabled
// ----------------------------------------------------------------
:host(.input-disabled) {
// color for the text within the input
--color: #{tokens.$ionic-color-neutral-400};
--background: #{tokens.$ionic-color-neutral-10};
pointer-events: none;
}
:host(.input-disabled:not(.ion-valid)) .input-bottom .helper-text,
:host(.input-disabled) .input-bottom .counter,
:host(.input-disabled) .label-text-wrapper {
color: tokens.$ionic-color-neutral-400;
}
:host(.input-disabled.has-focus.ion-valid) {
// TODO(FW-6112): Update to use the correct color token when rgb tokens are available
--border-color: rgba(var(--ionic-color-success-400-rgb, 82, 165, 24), 0.6);
}
:host(.input-disabled.ion-touched.ion-invalid) {
// TODO(FW-6112): Update to use the correct color token when rgb tokens are available
--border-color: rgba(var(--ionic-color-error-400-rgb, 247, 44, 44), 0.6);
}
:host(.input-disabled.ion-color) {
--border-color: #{current-color(base, 0.6)};
}
:host(.input-disabled.has-focus.ion-valid) .input-bottom .helper-text,
:host(.input-disabled.ion-touched.ion-invalid) .error-text,
:host(.input-disabled.ion-color) .input-bottom .helper-text,
:host(.input-disabled.ion-color) .helper-text {
opacity: 0.6;
}