From 94159291b27ddf1a859c8f3f87a0d6e54a8b5f13 Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Thu, 23 Jan 2020 16:57:47 -0500 Subject: [PATCH] feat(components): improve button states and add new css properties (#19440) Before users had to know the exact opacity that the MD/iOS spec called for in order to change the hover or focused background color. This allows them to change the background without having to know the opacity. - changes apply to Action Sheet (Buttons), Back Button, Button, FAB Button, Item, Menu Button, Segment Button, Tab Button - greatly reduces the requirement by users to set the background hover, focused states for dark modes and custom themes, also eliminates the need to know what the hover opacity is for each based on the spec - updates the MD dark theme per their spec - adds a component guide for internal use changing Ionic components references #18279 fixes #20213 fixes #19965 BREAKING CHANGE: *Activated Class* The `activated` class that is automatically added to buttons on press has been renamed to `ion-activated`. This will be more consistent with our `ion-focused` class we add and also will reduce conflicts with user's CSS. *CSS Variables* The `--background-hover`, `--background-focused` and `--background-activated` CSS variables on components that render native buttons will now have an opacity automatically set. If you are setting any of these like the following: ``` --background-hover: rgba(44, 44, 44, 0.08); ``` You will likely not see a hover state anymore. It should be updated to only set the desired color: ``` --background-hover: rgba(44, 44, 44); ``` If the opacity desired is something other than what the spec asks for, use: ``` --background-hover: rgba(44, 44, 44); --background-hover-opacity: 1; ``` --- .github/COMPONENT-GUIDE.md | 443 ++++++++++++++++++ BREAKING.md | 234 ++++++++- core/api.txt | 37 +- .../action-sheet/action-sheet.ios.scss | 58 ++- .../action-sheet/action-sheet.ios.vars.scss | 2 +- .../action-sheet/action-sheet.md.scss | 18 +- .../action-sheet/action-sheet.md.vars.scss | 7 - .../components/action-sheet/action-sheet.scss | 100 +++- .../components/action-sheet/action-sheet.tsx | 4 +- core/src/components/action-sheet/readme.md | 38 +- .../action-sheet/test/basic/index.html | 14 +- .../action-sheet/test/translucent/index.html | 4 +- core/src/components/alert/alert.ios.scss | 2 +- .../back-button/back-button.ios.scss | 14 +- .../back-button/back-button.md.scss | 14 +- .../components/back-button/back-button.scss | 70 ++- .../components/back-button/back-button.tsx | 3 +- core/src/components/back-button/readme.md | 66 +-- .../back-button/test/basic/index.html | 65 ++- .../back-button/test/standalone/index.html | 30 +- core/src/components/button/button.ios.scss | 96 ++-- core/src/components/button/button.md.scss | 58 ++- core/src/components/button/button.scss | 129 ++--- core/src/components/button/button.tsx | 6 +- core/src/components/button/readme.md | 47 +- .../components/button/test/anchor/index.html | 20 +- .../components/button/test/basic/index.html | 20 +- .../components/button/test/clear/index.html | 40 +- .../components/button/test/outline/index.html | 40 +- .../button/test/standalone/index.html | 10 +- core/src/components/button/test/states/e2e.ts | 10 + .../components/button/test/states/index.html | 115 +++++ .../components/button/test/toolbar/index.html | 18 +- core/src/components/buttons/buttons.ios.scss | 30 +- core/src/components/buttons/buttons.md.scss | 23 +- core/src/components/card/card.ios.scss | 2 +- core/src/components/card/readme.md | 24 +- .../src/components/card/test/basic/index.html | 8 +- .../card/test/translucent/index.html | 2 +- core/src/components/card/usage/angular.md | 8 +- core/src/components/card/usage/javascript.md | 8 +- core/src/components/card/usage/react.md | 8 +- core/src/components/card/usage/vue.md | 8 +- core/src/components/chip/chip.scss | 6 +- .../src/components/chip/test/basic/index.html | 146 +++--- core/src/components/chip/test/states/e2e.ts | 10 + .../components/chip/test/states/index.html | 285 +++++++++++ .../components/fab-button/fab-button.ios.scss | 38 +- .../components/fab-button/fab-button.md.scss | 44 +- .../fab-button/fab-button.md.vars.scss | 2 +- .../src/components/fab-button/fab-button.scss | 74 +-- core/src/components/fab-button/readme.md | 45 +- .../fab-button/test/standalone/index.html | 34 +- core/src/components/fab/test/states/e2e.ts | 10 + .../src/components/fab/test/states/index.html | 201 ++++++++ .../item-option/item-option.ios.scss | 4 +- .../item-sliding/test/basic/index.html | 2 +- core/src/components/item/item.ios.scss | 34 +- core/src/components/item/item.md.scss | 30 +- core/src/components/item/item.scss | 69 ++- core/src/components/item/readme.md | 73 +-- .../components/item/test/buttons/index.html | 14 +- .../components/item/test/colors/index.html | 4 +- .../item/test/standalone/index.html | 2 +- core/src/components/item/test/states/e2e.ts | 10 + .../components/item/test/states/index.html | 103 ++++ .../menu-button/menu-button.ios.scss | 22 +- .../menu-button/menu-button.md.scss | 28 +- .../components/menu-button/menu-button.scss | 62 ++- .../components/menu-button/menu-button.tsx | 14 +- core/src/components/menu-button/readme.md | 28 +- .../menu-button/test/basic/index.html | 17 +- core/src/components/picker/picker.ios.scss | 2 +- core/src/components/picker/picker.md.scss | 2 +- core/src/components/radio/radio.ios.scss | 1 + .../components/searchbar/searchbar.md.scss | 6 +- core/src/components/segment-button/readme.md | 58 +-- .../segment-button/segment-button.ios.scss | 90 +++- .../segment-button.ios.vars.scss | 12 +- .../segment-button/segment-button.md.scss | 84 +++- .../segment-button.md.vars.scss | 9 +- .../segment-button/segment-button.scss | 62 ++- .../segment-button/segment-button.tsx | 7 +- core/src/components/segment/segment.ios.scss | 27 -- core/src/components/segment/segment.md.scss | 67 --- .../components/segment/segment.md.vars.scss | 3 - core/src/components/segment/segment.scss | 25 - core/src/components/segment/segment.tsx | 15 +- .../components/segment/test/basic/index.html | 4 +- .../src/components/segment/test/colors/e2e.ts | 8 +- .../components/segment/test/colors/index.html | 267 ++++++----- .../segment/test/toolbar/index.html | 2 +- core/src/components/tab-bar/tab-bar.ios.scss | 2 +- core/src/components/tab-bar/tab-bar.md.scss | 2 +- .../components/tab-bar/test/basic/index.html | 288 ++++++------ .../tab-bar/test/scenarios/index.html | 333 ++++++------- core/src/components/tab-button/readme.md | 24 +- .../tab-button/tab-button.ios.vars.scss | 4 +- .../tab-button/tab-button.md.vars.scss | 4 +- .../src/components/tab-button/tab-button.scss | 41 +- core/src/components/tab-button/tab-button.tsx | 6 +- core/src/components/toast/toast.ios.scss | 2 +- .../components/toolbar/test/colors/index.html | 64 +++ .../toolbar/test/scenarios/index.html | 18 +- .../components/toolbar/toolbar.md.vars.scss | 3 - core/src/themes/ionic.mixins.scss | 10 + core/src/themes/ionic.theme.default.ios.scss | 6 +- core/src/themes/ionic.theme.default.md.scss | 6 +- .../themes/test/css-variables/css/dark.css | 1 + .../themes/test/css-variables/css/oceanic.css | 3 +- .../themes/test/css-variables/css/toolbar.css | 26 + .../themes/test/css-variables/css/vibrant.css | 16 - core/src/themes/test/css-variables/index.html | 152 +++--- core/src/utils/tap-click.ts | 2 +- 114 files changed, 3641 insertions(+), 1487 deletions(-) create mode 100644 .github/COMPONENT-GUIDE.md create mode 100644 core/src/components/button/test/states/e2e.ts create mode 100644 core/src/components/button/test/states/index.html create mode 100644 core/src/components/chip/test/states/e2e.ts create mode 100644 core/src/components/chip/test/states/index.html create mode 100644 core/src/components/fab/test/states/e2e.ts create mode 100644 core/src/components/fab/test/states/index.html create mode 100644 core/src/components/item/test/states/e2e.ts create mode 100644 core/src/components/item/test/states/index.html create mode 100644 core/src/themes/test/css-variables/css/toolbar.css diff --git a/.github/COMPONENT-GUIDE.md b/.github/COMPONENT-GUIDE.md new file mode 100644 index 0000000000..7446518da8 --- /dev/null +++ b/.github/COMPONENT-GUIDE.md @@ -0,0 +1,443 @@ +# Ionic Component Implementation Guide + +- [Button States](#button-states) + * [Component Structure](#component-structure) + * [Activated](#activated) + * [Disabled](#disabled) + * [Focused](#focused) + * [Hover](#hover) + * [Ripple Effect](#ripple-effect) + * [Example Components](#example-components) + * [References](#references) +- [Rendering Anchor or Button](#rendering-anchor-or-button) + * [Example Components](#example-components-1) + * [Component Structure](#component-structure-1) +- [Converting Scoped to Shadow](#converting-scoped-to-shadow) + +## Button States + +Any component that renders a button should have the following states: [`activated`](#activated), [`disabled`](#disabled), [`focused`](#focused), [`hover`](#hover). It should also have a [Ripple Effect](#ripple-effect) component added for Material Design. + +### Component Structure + +#### JavaScript + +A component that renders a native button should use the following structure: + +```jsx + + + +``` + +Any other attributes and classes that are included are irrelevant to the button states, but it's important that this structure is followed and the classes above exist. In some cases they may be named something else that makes more sense, such as in item. + + +#### CSS + +A mixin called `button-state()` has been added to make it easier to setup the states in each component. + +```scss +@mixin button-state() { + @include position(0, 0, 0, 0); + + position: absolute; + + content: ""; + + opacity: 0; +} +``` + +The following styles should be set for the CSS to work properly. Note that the `button-state()` mixin is included in the `::after` pseudo element of the native button. + +```scss +.button-native { + /** + * All other CSS in this selector is irrelevant to button states + * but the following are required styles + */ + + position: relative; + + overflow: hidden; +} + +.button-native::after { + @include button-state(); +} + +.button-inner { + /** + * All other CSS in this selector is irrelevant to button states + * but the following are required styles + */ + + position: relative; + + z-index: 1; +} +``` + + +### Activated + +The activated state should be enabled for elements with actions on "press". It usually changes the opacity or background of an element. + +> Make sure the component has the correct [component structure](#component-structure) before continuing. + +#### JavaScript + +The `ion-activatable` class needs to be set on an element that can be activated: + +```jsx +render() { + return ( + + + + ); +} +``` + +Once that is done, the element will get the `ion-activated` class added on press. + +In addition to setting that class, `ion-activatable-instant` can be set in order to have an instant press with no delay: + +```jsx + +``` + +#### CSS + +```css + /** + * @prop --color-activated: Color of the button when pressed + * @prop --background-activated: Background of the button when pressed + * @prop --background-activated-opacity: Opacity of the background when pressed + */ +``` + +Style the `ion-activated` class based on the spec for that element: + +```scss +:host(.ion-activated) .button-native { + color: var(--color-activated); + + &::after { + background: var(--background-activated); + + opacity: var(--background-activated-opacity); + } +} +``` + +> Order is important! Activated should be before the focused & hover states. + + +#### User Customization + +Setting the activated state on the `::after` pseudo-element allows the user to customize the activated state without knowing what the default opacity is set at. A user can customize in the following ways to have a solid red background on press, or they can leave out `--background-activated-opacity` and the button will use the default activated opacity to match the spec. + +```css +ion-button { + --background-activated: red; + --background-activated-opacity: 1; +} +``` + + +### Disabled + +The disabled state should be set via prop on all components that render a native button. Setting a disabled state will change the opacity or color of the button and remove click events from firing. + +#### JavaScript + +The `disabled` property should be set on the component: + +```jsx +/** + * If `true`, the user cannot interact with the button. + */ +@Prop({ reflectToAttr: true }) disabled = false; +``` + +Then, the render function should add the [`aria-disabled`](https://www.w3.org/WAI/PF/aria/states_and_properties#aria-disabled) role to the host, a class that is the element tag name followed by `disabled`, and pass the `disabled` attribute to the native button: + +```jsx +render() { + const { disabled } = this; + + return ( + + + + ); +} +``` + +> Note: if the class being added was for `ion-back-button` it would be `back-button-disabled`. + +#### CSS + +The following CSS _at the bare minimum_ should be added for the disabled class, but it should be styled to match the spec: + +```css +:host(.button-disabled) { + cursor: default; + opacity: .5; + pointer-events: none; +} +``` + +#### User Customization + +TODO + +### Focused + +The focused state should be enabled for elements with actions when tabbed to via the keyboard. This will only work inside of an `ion-app`. It usually changes the opacity or background of an element. + +> Make sure the component has the correct [component structure](#component-structure) before continuing. + +#### JavaScript + +The `ion-focusable` class needs to be set on an element that can be focused: + +```jsx +render() { + return ( + + + + ); +} +``` + +Once that is done, the element will get the `ion-focused` class added when the element is tabbed to. + +#### CSS + +Components should be written to include the following focused variables for styling: + +```css + /** + * @prop --color-focused: Color of the button when tabbed to with the keyboard + * @prop --background-focused: Background of the button when tabbed to with the keyboard + * @prop --background-focused-opacity: Opacity of the background when tabbed to with the keyboard + */ +``` + +Style the `ion-focused` class based on the spec for that element: + +```scss +:host(.ion-focused) .button-native { + color: var(--color-focused); + + &::after { + background: var(--background-focused); + + opacity: var(--background-focused-opacity); + } +} +``` + +> Order is important! Focused should be after the activated and before the hover state. + + +#### User Customization + +Setting the focused state on the `::after` pseudo-element allows the user to customize the focused state without knowing what the default opacity is set at. A user can customize in the following ways to have a solid red background on focus, or they can leave out `--background-focused-opacity` and the button will use the default focus opacity to match the spec. + +```css +ion-button { + --background-focused: red; + --background-focused-opacity: 1; +} +``` + + +### Hover + +The [hover state](https://developer.mozilla.org/en-US/docs/Web/CSS/:hover) happens when a user moves their cursor on top of an element without pressing on it. It should not happen on mobile, only on desktop devices that support hover. + +> Make sure the component has the correct [component structure](#component-structure) before continuing. + +#### CSS + +Components should be written to include the following hover variables for styling: + +```css + /** + * @prop --color-hover: Color of the button on hover + * @prop --background-hover: Background of the button on hover + * @prop --background-hover-opacity: Opacity of the background on hover + */ +``` + +Style the `:hover` based on the spec for that element: + +```scss +@media (any-hover: hover) { + :host(:hover) .button-native { + color: var(--color-hover); + + &::after { + background: var(--background-hover); + + opacity: var(--background-hover-opacity); + } + } +} +``` + +> Order is important! Hover should be after the activated and focused states. + + +#### User Customization + +Setting the hover state on the `::after` pseudo-element allows the user to customize the hover state without knowing what the default opacity is set at. A user can customize in the following ways to have a solid red background on hover, or they can leave out `--background-hover-opacity` and the button will use the default hover opacity to match the spec. + +```css +ion-button { + --background-hover: red; + --background-hover-opacity: 1; +} +``` + + +### Ripple Effect + +The ripple effect should be added to elements for Material Design. It *requires* the `ion-activatable` class to be set on the parent element to work, and relative positioning on the parent. + +```jsx + render() { + const mode = getIonMode(this); + +return ( + + + +); +``` + +The ripple effect can also accept a different `type`. By default it is `"bounded"` which will expand the ripple effect from the click position outwards. To add a ripple effect that always starts in the center of the element and expands in a circle, set the type to `"unbounded"`. An unbounded ripple will exceed the container, so add `overflow: hidden` to the parent to prevent this. + +Make sure to style the ripple effect for that component to accept a color: + +```css +ion-ripple-effect { + color: var(--ripple-color); +} +``` + + +### Example Components + +- [ion-button](https://github.com/ionic-team/ionic/tree/master/core/src/components/button) +- [ion-back-button](https://github.com/ionic-team/ionic/tree/master/core/src/components/back-button) +- [ion-menu-button](https://github.com/ionic-team/ionic/tree/master/core/src/components/menu-button) + +### References + +- [Material Design States](https://material.io/design/interaction/states.html) +- [iOS Buttons](https://developer.apple.com/design/human-interface-guidelines/ios/controls/buttons/) + + +## Rendering Anchor or Button + +Certain components can render an `` or a ` } @@ -266,6 +267,7 @@ const buttonClass = (button: ActionSheetButton): CssClassMap => { return { 'action-sheet-button': true, 'ion-activatable': true, + 'ion-focusable': true, [`action-sheet-${button.role}`]: button.role !== undefined, ...getClassMap(button.cssClass), }; diff --git a/core/src/components/action-sheet/readme.md b/core/src/components/action-sheet/readme.md index fcfb07a4e4..a62765d076 100644 --- a/core/src/components/action-sheet/readme.md +++ b/core/src/components/action-sheet/readme.md @@ -319,19 +319,31 @@ Type: `Promise` ## CSS Custom Properties -| Name | Description | -| ------------------------ | -------------------------------------------------- | -| `--backdrop-opacity` | Opacity of the backdrop | -| `--background` | Background of the action sheet group | -| `--background-activated` | Background of the action sheet button when pressed | -| `--background-selected` | Background of the selected action sheet button | -| `--color` | Color of the action sheet text | -| `--height` | height of the action sheet | -| `--max-height` | Maximum height of the action sheet | -| `--max-width` | Maximum width of the action sheet | -| `--min-height` | Minimum height of the action sheet | -| `--min-width` | Minimum width of the action sheet | -| `--width` | Width of the action sheet | +| Name | Description | +| --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | +| `--backdrop-opacity` | Opacity of the backdrop | +| `--background` | Background of the action sheet group | +| `--button-background` | Background of the action sheet button | +| `--button-background-activated` | Background of the action sheet button when pressed. Note: setting this will interfere with the Material Design ripple. | +| `--button-background-activated-opacity` | Opacity of the action sheet button background when pressed | +| `--button-background-focused` | Background of the action sheet button when tabbed to | +| `--button-background-focused-opacity` | Opacity of the action sheet button background when tabbed to | +| `--button-background-hover` | Background of the action sheet button on hover | +| `--button-background-hover-opacity` | Opacity of the action sheet button background on hover | +| `--button-background-selected` | Background of the selected action sheet button | +| `--button-background-selected-opacity` | Opacity of the selected action sheet button background | +| `--button-color` | Color of the action sheet button | +| `--button-color-activated` | Color of the action sheet button when pressed | +| `--button-color-focused` | Color of the action sheet button when tabbed to | +| `--button-color-hover` | Color of the action sheet button on hover | +| `--button-color-selected` | Color of the selected action sheet button | +| `--color` | Color of the action sheet text | +| `--height` | height of the action sheet | +| `--max-height` | Maximum height of the action sheet | +| `--max-width` | Maximum width of the action sheet | +| `--min-height` | Minimum height of the action sheet | +| `--min-width` | Minimum width of the action sheet | +| `--width` | Width of the action sheet | ## Dependencies diff --git a/core/src/components/action-sheet/test/basic/index.html b/core/src/components/action-sheet/test/basic/index.html index 7771929482..6acfed47ea 100644 --- a/core/src/components/action-sheet/test/basic/index.html +++ b/core/src/components/action-sheet/test/basic/index.html @@ -40,10 +40,10 @@ diff --git a/core/src/components/back-button/test/standalone/index.html b/core/src/components/back-button/test/standalone/index.html index ecf7402b08..8514a537e2 100644 --- a/core/src/components/back-button/test/standalone/index.html +++ b/core/src/components/back-button/test/standalone/index.html @@ -34,15 +34,15 @@

- - - - - - - - - + + + + + + + + +

Custom

@@ -54,13 +54,13 @@ - + - + Default @@ -68,7 +68,7 @@ - + Custom @@ -76,7 +76,7 @@ - + Secondary @@ -84,7 +84,7 @@ - + Danger @@ -92,7 +92,7 @@ - + Dark diff --git a/core/src/components/button/button.ios.scss b/core/src/components/button/button.ios.scss index 2c507bd643..66c06a92f3 100644 --- a/core/src/components/button/button.ios.scss +++ b/core/src/components/button/button.ios.scss @@ -23,20 +23,19 @@ letter-spacing: #{$button-ios-letter-spacing}; } + // iOS Solid Button // -------------------------------------------------- :host(.button-solid) { --background-activated: #{ion-color(primary, shade)}; + --background-focused: #{ion-color(primary, shade)}; + --background-hover: #{ion-color(primary, tint)}; + --background-activated-opacity: 1; + --background-focused-opacity: 1; + --background-hover-opacity: 1; } -:host(.button-solid.activated) { - --opacity: #{$button-ios-opacity-activated}; -} - -:host(.button-solid.activated.ion-color) .button-native { - background: current-color(shade); -} // iOS Outline Button // -------------------------------------------------- @@ -46,28 +45,21 @@ --border-width: #{$button-ios-outline-border-width}; --border-style: #{$button-ios-outline-border-style}; --background-activated: #{ion-color(primary, base)}; - --background-focused: #{ion-color(primary, base, .1)}; + --background-focused: #{ion-color(primary, base)}; + --background-hover: transparent; + --background-focused-opacity: .1; --color-activated: #{ion-color(primary, contrast)}; } -:host(.button-outline.activated.ion-color) .button-native { - background: current-color(base); - color: current-color(contrast); -} - // iOS Clear Button // -------------------------------------------------- -:host(.button-clear.activated) { - --opacity: #{$button-ios-clear-opacity-activated}; -} - :host(.button-clear) { --background-activated: transparent; - --background-focused: #{ion-color(primary, base, .1)}; - --color-activated: #{ion-color(primary, base)}; - --color-focused: #{ion-color(primary, base)}; + --background-focused: #{ion-color(primary, base)}; + --background-hover: transparent; + --background-focused-opacity: .1; font-size: #{$button-ios-clear-font-size}; font-weight: #{$button-ios-clear-font-weight}; @@ -124,29 +116,63 @@ } -// iOS Button Focus +// iOS Button Activated +// -------------------------------------------------- + +:host(.button-clear.ion-activated) { + opacity: #{$button-ios-clear-opacity-activated}; +} + +:host(.button-outline.ion-activated.ion-color) .button-native { + color: current-color(contrast); + + &::after { + background: current-color(base); + } +} + +:host(.button-solid.ion-color.ion-activated) .button-native::after { + background: #{current-color(shade)}; +} + +// iOS Button Focused +// -------------------------------------------------- + +:host(.button-outline.ion-focused.ion-color) .button-native, +:host(.button-clear.ion-focused.ion-color) .button-native { + color: current-color(base); + + &::after { + background: current-color(base); + } +} + +:host(.button-solid.ion-color.ion-focused) .button-native::after { + background: #{current-color(shade)}; +} + +// iOS Button Hover // -------------------------------------------------- @media (any-hover: hover) { - :host(.button-solid:hover) { - --opacity: #{$button-ios-opacity-hover}; - } - + // Clear and outline buttons use opacity so set + // background to transparent :host(.button-clear:hover), :host(.button-outline:hover) { - --opacity: #{$button-ios-clear-opacity-hover}; + opacity: #{$button-ios-clear-opacity-hover}; } - // Since iOS changes the opacity on hover, - // we want to keep the background if focused - // or activated - :host(.ion-focused:hover) { - --background-hover: var(--background-focused); - --color-hover: var(--color-focused); + :host(.button-clear.ion-color:hover) .button-native, + :host(.button-outline.ion-color:hover) .button-native { + color: #{current-color(base)}; + + &::after { + background: transparent; + } } - :host(.activated:hover) { - --background-hover: var(--background-activated); - --color-hover: var(--color-activated); + // Solid buttons use the tint background + :host(.button-solid.ion-color:hover) .button-native::after { + background: #{current-color(tint)}; } } diff --git a/core/src/components/button/button.md.scss b/core/src/components/button/button.md.scss index 8639261787..4a1ca0a211 100644 --- a/core/src/components/button/button.md.scss +++ b/core/src/components/button/button.md.scss @@ -30,11 +30,16 @@ // -------------------------------------------------- :host(.button-solid) { - --background-activated: var(--background); + --background-activated: transparent; + --background-hover: #{ion-color(primary, contrast)}; + --background-focused: #{ion-color(primary, contrast)}; + --background-activated-opacity: 0; + --background-focused-opacity: .24; + --background-hover-opacity: .08; --box-shadow: #{$button-md-box-shadow}; } -:host(.button-solid.activated) { +:host(.button-solid.ion-activated) { --box-shadow: #{$button-md-box-shadow-activated}; } @@ -46,12 +51,14 @@ --border-style: solid; --box-shadow: none; --background-activated: transparent; - --background-focused: #{ion-color(primary, base, .1)}; - --background-hover: #{ion-color(primary, base, .04)}; - --color-activated: #{ion-color(primary, base)}; + --background-focused: #{ion-color(primary, base)}; + --background-hover: #{ion-color(primary, base)}; + --background-activated-opacity: 0; + --background-focused-opacity: .12; + --background-hover-opacity: .04; } -:host(.button-outline.activated.ion-color) .button-native { +:host(.button-outline.ion-activated.ion-color) .button-native { background: transparent; } @@ -61,10 +68,11 @@ :host(.button-clear) { --background-activated: transparent; - --background-focused: #{ion-color(primary, base, .1)}; - --background-hover: #{ion-color(primary, base, .04)}; - --color-activated: #{ion-color(primary, base)}; - --color-focused: #{ion-color(primary, base)}; + --background-focused: #{ion-color(primary, base)}; + --background-hover: #{ion-color(primary, base)}; + --background-activated-opacity: 0; + --background-focused-opacity: .12; + --background-hover-opacity: .04; } @@ -121,13 +129,33 @@ // Material Design Button: Hover // -------------------------------------------------- +:host(.button-solid.ion-color.ion-activated) .button-native::after, +:host(.button-solid.ion-color.ion-focused) .button-native::after { + background: #{current-color(contrast)}; + + opacity: .24; +} + +:host(.button-clear.ion-color.ion-activated) .button-native::after, +:host(.button-clear.ion-color.ion-focused) .button-native::after, +:host(.button-outline.ion-color.ion-activated) .button-native::after, +:host(.button-outline.ion-color.ion-focused) .button-native::after { + background: #{current-color(base)}; + + opacity: .12; +} + @media (any-hover: hover) { - :host(.button-solid.ion-color:hover) .button-native { - background: #{current-color(tint)}; + :host(.button-solid.ion-color:hover) .button-native::after { + background: #{current-color(contrast)}; + + opacity: .08; } - :host(.button-clear.ion-color:hover) .button-native, - :host(.button-outline.ion-color:hover) .button-native { - background: #{current-color(base, .04)}; + :host(.button-clear.ion-color:hover) .button-native::after, + :host(.button-outline.ion-color:hover) .button-native::after { + background: #{current-color(base)}; + + opacity: .04; } } diff --git a/core/src/components/button/button.scss b/core/src/components/button/button.scss index 63111d87f8..cc3f5d3f5c 100644 --- a/core/src/components/button/button.scss +++ b/core/src/components/button/button.scss @@ -6,9 +6,12 @@ :host { /** * @prop --background: Background of the button - * @prop --background-activated: Background of the button when pressed + * @prop --background-activated: Background of the button when pressed. Note: setting this will interfere with the Material Design ripple. + * @prop --background-activated-opacity: Opacity of the button when pressed * @prop --background-focused: Background of the button when focused with the tab key + * @prop --background-focused-opacity: Opacity of the button when focused with the tab key * @prop --background-hover: Background of the button on hover + * @prop --background-hover-opacity: Opacity of the background on hover * * @prop --color: Text color of the button * @prop --color-activated: Text color of the button when pressed @@ -37,7 +40,9 @@ --border-width: initial; --border-color: initial; --border-style: initial; - --color-hover: initial; + --color-activated: var(--color); + --color-focused: var(--color); + --color-hover: var(--color); --box-shadow: none; display: inline-block; @@ -63,12 +68,8 @@ } :host(.button-disabled) { - --opacity: .5; - pointer-events: none; -} - -:host(.button-disabled) .button-native { cursor: default; + opacity: .5; pointer-events: none; } @@ -78,22 +79,7 @@ // Default Solid Color :host(.button-solid) { --background: #{ion-color(primary, base)}; - --background-focused: #{ion-color(primary, shade)}; - --background-hover: #{ion-color(primary, tint)}; --color: #{ion-color(primary, contrast)}; - --color-activated: #{ion-color(primary, contrast)}; - --color-focused: #{ion-color(primary, contrast)}; -} - -// Solid Button with Color -:host(.button-solid.ion-color) .button-native { - background: current-color(base); - color: current-color(contrast); -} - -// Focused/Activated Solid Button with Color -:host(.button-solid.ion-color.ion-focused) .button-native { - background: #{current-color(shade)}; } @@ -105,20 +91,6 @@ --border-color: #{ion-color(primary, base)}; --background: transparent; --color: #{ion-color(primary, base)}; - --color-focused: #{ion-color(primary, base)}; -} - -// Outline Button with Color -:host(.button-outline.ion-color) .button-native { - border-color: current-color(base); - - background: transparent; - color: current-color(base); -} - -:host(.button-outline.ion-focused.ion-color) .button-native { - background: current-color(base, .1); - color: current-color(base); } @@ -132,23 +104,6 @@ --color: #{ion-color(primary, base)}; } -// Clear Button with Color -:host(.button-clear.ion-color) .button-native { - background: transparent; - color: current-color(base); -} - -// Focused Clear Button with Color -:host(.button-clear.ion-focused.ion-color) .button-native { - background: current-color(base, .1); - color: current-color(base); -} - -// Activated Clear Button with Color -:host(.button-clear.activated.ion-color) .button-native { - background: transparent; -} - // Block Button // -------------------------------------------------- @@ -229,6 +184,8 @@ opacity: var(--opacity); overflow: var(--overflow); + overflow: hidden; + z-index: 0; box-sizing: border-box; appearance: none; @@ -240,6 +197,7 @@ .button-inner { display: flex; + position: relative; flex-flow: row nowrap; flex-shrink: 0; @@ -248,6 +206,8 @@ width: 100%; height: 100%; + + z-index: 1; } @@ -279,22 +239,69 @@ ion-ripple-effect { color: var(--ripple-color); } -// Button: Hover + +// Button: States // -------------------------------------------------- -:host(.ion-focused) .button-native { - background: var(--background-focused); - color: var(--color-focused); +.button-native::after { + @include button-state(); } -:host(.activated) .button-native { - background: var(--background-activated); +// Button Activated +:host(.ion-activated) { color: var(--color-activated); } +:host(.ion-activated) .button-native::after { + background: var(--background-activated); + + opacity: var(--background-activated-opacity); +} + +// Button Focused +:host(.ion-focused) { + color: var(--color-focused); +} + +:host(.ion-focused) .button-native::after { + background: var(--background-focused); + + opacity: var(--background-focused-opacity); +} + +// Button Hover @media (any-hover: hover) { - :host(:hover) .button-native { - background: var(--background-hover); + :host(:hover) { color: var(--color-hover); } + + :host(:hover) .button-native::after { + background: var(--background-hover); + + opacity: var(--background-hover-opacity); + } +} + + +// Button Colors +// -------------------------------------------------- + +// Solid Button with Color +:host(.button-solid.ion-color) .button-native { + background: current-color(base); + color: current-color(contrast); +} + +// Outline Button with Color +:host(.button-outline.ion-color) .button-native { + border-color: current-color(base); + + background: transparent; + color: current-color(base); +} + +// Clear Button with Color +:host(.button-clear.ion-color) .button-native { + background: transparent; + color: current-color(base); } diff --git a/core/src/components/button/button.tsx b/core/src/components/button/button.tsx index 140b6b4e39..51b8414437 100644 --- a/core/src/components/button/button.tsx +++ b/core/src/components/button/button.tsx @@ -13,6 +13,9 @@ import { createColorClasses, openURL } from '../../utils/theme'; * @slot icon-only - Should be used on an icon in a button that has no text. * @slot start - Content is placed to the left of the button text in LTR, and to the right in RTL. * @slot end - Content is placed to the right of the button text in LTR, and to the left in RTL. + * + * @part button - The native button or anchor tag that is rendered. + * @part button-inner - The span inside of the native button or anchor. */ @Component({ tag: 'ion-button', @@ -218,8 +221,9 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf disabled={disabled} onFocus={this.onFocus} onBlur={this.onBlur} + part="button" > - + diff --git a/core/src/components/button/readme.md b/core/src/components/button/readme.md index a5171eeb97..7c1cef346e 100644 --- a/core/src/components/button/readme.md +++ b/core/src/components/button/readme.md @@ -252,28 +252,31 @@ export const ButtonExample: React.FC = () => ( ## CSS Custom Properties -| Name | Description | -| ------------------------ | --------------------------------------------------------------------------------------------------------- | -| `--background` | Background of the button | -| `--background-activated` | Background of the button when pressed | -| `--background-focused` | Background of the button when focused with the tab key | -| `--background-hover` | Background of the button on hover | -| `--border-color` | Border color of the button | -| `--border-radius` | Border radius of the button | -| `--border-style` | Border style of the button | -| `--border-width` | Border width of the button | -| `--box-shadow` | Box shadow of the button | -| `--color` | Text color of the button | -| `--color-activated` | Text color of the button when pressed | -| `--color-focused` | Text color of the button when focused with the tab key | -| `--color-hover` | Text color of the button when hover | -| `--opacity` | Opacity of the button | -| `--padding-bottom` | Bottom padding of the button | -| `--padding-end` | Right padding if direction is left-to-right, and left padding if direction is right-to-left of the button | -| `--padding-start` | Left padding if direction is left-to-right, and right padding if direction is right-to-left of the button | -| `--padding-top` | Top padding of the button | -| `--ripple-color` | Color of the button ripple effect | -| `--transition` | Transition of the button | +| Name | Description | +| -------------------------------- | --------------------------------------------------------------------------------------------------------- | +| `--background` | Background of the button | +| `--background-activated` | Background of the button when pressed. Note: setting this will interfere with the Material Design ripple. | +| `--background-activated-opacity` | Opacity of the button when pressed | +| `--background-focused` | Background of the button when focused with the tab key | +| `--background-focused-opacity` | Opacity of the button when focused with the tab key | +| `--background-hover` | Background of the button on hover | +| `--background-hover-opacity` | Opacity of the background on hover | +| `--border-color` | Border color of the button | +| `--border-radius` | Border radius of the button | +| `--border-style` | Border style of the button | +| `--border-width` | Border width of the button | +| `--box-shadow` | Box shadow of the button | +| `--color` | Text color of the button | +| `--color-activated` | Text color of the button when pressed | +| `--color-focused` | Text color of the button when focused with the tab key | +| `--color-hover` | Text color of the button when hover | +| `--opacity` | Opacity of the button | +| `--padding-bottom` | Bottom padding of the button | +| `--padding-end` | Right padding if direction is left-to-right, and left padding if direction is right-to-left of the button | +| `--padding-start` | Left padding if direction is left-to-right, and right padding if direction is right-to-left of the button | +| `--padding-top` | Top padding of the button | +| `--ripple-color` | Color of the button ripple effect | +| `--transition` | Transition of the button | ## Dependencies diff --git a/core/src/components/button/test/anchor/index.html b/core/src/components/button/test/anchor/index.html index d073133707..56adf28a40 100644 --- a/core/src/components/button/test/anchor/index.html +++ b/core/src/components/button/test/anchor/index.html @@ -23,43 +23,43 @@

Default - Default.activated + Default.activated

Primary - Primary.activated + Primary.activated

Secondary - Secondary.activated + Secondary.activated

Tertiary - Tertiary.activated + Tertiary.activated

Success - Success.activated + Success.activated

Warning - Warning.activated + Warning.activated

Danger - Danger.activated + Danger.activated

Light - Light.activated + Light.activated

Medium - Medium.activated + Medium.activated

Dark - Dark.activated + Dark.activated

Disabled diff --git a/core/src/components/button/test/basic/index.html b/core/src/components/button/test/basic/index.html index 453beff75c..8101cfb3c4 100644 --- a/core/src/components/button/test/basic/index.html +++ b/core/src/components/button/test/basic/index.html @@ -24,61 +24,61 @@

Default Default.focused - Default.activated + Default.activated

Primary Primary.focused - Primary.activated + Primary.activated

Secondary Secondary.focused - Secondary.activated + Secondary.activated

Tertiary Tertiary.focused - Tertiary.activated + Tertiary.activated

Success Success.focused - Success.activated + Success.activated

Warning Warning.focused - Warning.activated + Warning.activated

Danger Danger.focused - Danger.activated + Danger.activated

Light Light.focused - Light.activated + Light.activated

Medium Medium.focused - Medium.activated + Medium.activated

Dark Dark.focused - Dark.activated + Dark.activated

diff --git a/core/src/components/button/test/clear/index.html b/core/src/components/button/test/clear/index.html index b8c3119cab..d116a981d1 100644 --- a/core/src/components/button/test/clear/index.html +++ b/core/src/components/button/test/clear/index.html @@ -23,72 +23,72 @@

Default - Default.activated + Default.activated Default.focused - Default.activated.focused + Default.activated.focused

Primary - Primary.activated + Primary.activated Primary.focused - Primary.activated.focused + Primary.activated.focused

Secondary - Secondary.activated + Secondary.activated Secondary.focused - Secondary.activated.focused + Secondary.activated.focused

Tertiary - Tertiary.activated + Tertiary.activated Tertiary.focused - Tertiary.activated.focused + Tertiary.activated.focused

Success - Success.activated + Success.activated Success.focused - Success.activated.focused + Success.activated.focused

Warning - Warning.activated + Warning.activated Warning.focused - Warning.activated.focused + Warning.activated.focused

Danger - Danger.activated + Danger.activated Danger.focused - Danger.activated.focused + Danger.activated.focused

Light - Light.activated + Light.activated Light.focused - Light.activated.focused + Light.activated.focused

Medium - Medium.activated + Medium.activated Medium.focused - Medium.activated.focused + Medium.activated.focused

Dark - Dark.activated + Dark.activated Dark.focused - Dark.activated.focused + Dark.activated.focused

Disabled diff --git a/core/src/components/button/test/outline/index.html b/core/src/components/button/test/outline/index.html index b347713a9b..0ac765ec0b 100644 --- a/core/src/components/button/test/outline/index.html +++ b/core/src/components/button/test/outline/index.html @@ -23,72 +23,72 @@

Default - Default.activated + Default.activated Default.focused - Default.activated.focused + Default.activated.focused

Primary - Primary.activated + Primary.activated Primary.focused - Primary.activated.focused + Primary.activated.focused

Secondary - Secondary.activated + Secondary.activated Secondary.focused - Secondary.activated.focused + Secondary.activated.focused

Tertiary - Tertiary.activated + Tertiary.activated Tertiary.focused - Tertiary.activated.focused + Tertiary.activated.focused

Success - Success.activated + Success.activated Success.focused - Success.activated.focused + Success.activated.focused

Warning - Warning.activated + Warning.activated Warning.focused - Warning.activated.focused + Warning.activated.focused

Danger - Danger.activated + Danger.activated Danger.focused - Danger.activated.focused + Danger.activated.focused

Light - Light.activated + Light.activated Light.focused - Light.activated.focused + Light.activated.focused

Medium - Medium.activated + Medium.activated Medium.focused - Medium.activated.focused + Medium.activated.focused

Dark - Dark.activated + Dark.activated Dark.focused - Dark.activated.focused + Dark.activated.focused

Disabled diff --git a/core/src/components/button/test/standalone/index.html b/core/src/components/button/test/standalone/index.html index e8e41bb42b..20e27eefdb 100644 --- a/core/src/components/button/test/standalone/index.html +++ b/core/src/components/button/test/standalone/index.html @@ -53,8 +53,8 @@ custom - custom.focused - custom.activated + custom.focused + custom.activated custom w/ secondary custom medium @@ -71,7 +71,7 @@ Custom - Custom.a + Custom.a Bar @@ -101,7 +101,7 @@ .custom { --background: lightpink; - --background-hover: rgba(255, 182, 193, 0.5); + --background-hover: #ffb6c1; --background-activated: green; --color: #222; --color-activated: white; @@ -110,7 +110,7 @@ .medium { --color: #989aa2; - --background-hover: rgba(152, 154, 162, 0.4); + --background-hover: #989aa2; } diff --git a/core/src/components/button/test/states/e2e.ts b/core/src/components/button/test/states/e2e.ts new file mode 100644 index 0000000000..f25ab26fc4 --- /dev/null +++ b/core/src/components/button/test/states/e2e.ts @@ -0,0 +1,10 @@ +import { newE2EPage } from '@stencil/core/testing'; + +test('button: states', async () => { + const page = await newE2EPage({ + url: '/src/components/button/test/states?ionic:_testing=true' + }); + + const compare = await page.compareScreenshot(); + expect(compare).toMatchScreenshot(); +}); diff --git a/core/src/components/button/test/states/index.html b/core/src/components/button/test/states/index.html new file mode 100644 index 0000000000..b804cd495e --- /dev/null +++ b/core/src/components/button/test/states/index.html @@ -0,0 +1,115 @@ + + + + + + Button - States + + + + + + + + + + +

Default

+

+ Default + + Round + Outline + Clear + Default + + Round + Outline + Clear +

+ +

Focused

+

+ Default + + Round + Outline + Clear + Default + + Round + Outline + Clear +

+ +

Activated

+

+ Default + + Round + Outline + Clear + Default + + Round + Outline + Clear +

+ +

Custom

+

+ Default + + Round + Outline + Clear + Default + + Round + Outline + Clear + Default + + Round + Outline + Clear + Default + + Round + Outline + Clear + Default + + Round + Outline + Clear + Default + + Round + Outline + Clear +

+
+ + + + + + diff --git a/core/src/components/button/test/toolbar/index.html b/core/src/components/button/test/toolbar/index.html index de8ecc726f..c6cc303a93 100644 --- a/core/src/components/button/test/toolbar/index.html +++ b/core/src/components/button/test/toolbar/index.html @@ -99,15 +99,15 @@ - + - + - + @@ -135,17 +135,17 @@ - + - + Solid Solid Activated - + Help @@ -172,16 +172,16 @@ - + - + Star - + diff --git a/core/src/components/buttons/buttons.ios.scss b/core/src/components/buttons/buttons.ios.scss index e06ac95bcc..3979d975da 100644 --- a/core/src/components/buttons/buttons.ios.scss +++ b/core/src/components/buttons/buttons.ios.scss @@ -29,27 +29,25 @@ :host-context(.ion-color)::slotted(*) .button { --color: initial; --border-color: initial; - --background-focused: #{current-color(contrast, .1)}; - + --background-focused: #{current-color(contrast)}; } :host-context(.ion-color)::slotted(*) .button-solid { --background: #{current-color(contrast)}; - --background-activated: #{current-color(contrast, .8)}; - --background-focused: #{current-color(contrast, .6)}; + --background-focused: #000; + --background-focused-opacity: .12; + --background-activated: #000; + --background-activated-opacity: .12; --color: #{current-color(base)}; --color-focused: #{current-color(base)}; } :host-context(.ion-color)::slotted(*) .button-clear { - --background-focused: #{current-color(contrast, .1)}; --color-activated: #{current-color(contrast)}; --color-focused: #{current-color(contrast)}; } :host-context(.ion-color)::slotted(*) .button-outline { - --background-activated: #{current-color(contrast)}; - --background-focused: #{current-color(contrast, .1)}; --color-activated: #{current-color(base)}; --color-focused: #{current-color(contrast)}; } @@ -58,35 +56,39 @@ // iOS Toolbar Button Clear // -------------------------------------------------- -:host-context(ion-toolbar:not(.ion-color))::slotted(*) .button-clear { +:host-context(ion-toolbar:not(.ion-color))::slotted(*) .button-clear:not(.ion-color) { --color: #{var(--ion-toolbar-color, ion-color(primary, base))}; - --color-activated: #{$toolbar-ios-color-activated}; --color-focused: #{var(--ion-toolbar-color, ion-color(primary, base))}; + --background-focused: #{var(--ion-toolbar-color, ion-color(primary, base))}; } // iOS Toolbar Button Outline // -------------------------------------------------- -:host-context(ion-toolbar:not(.ion-color))::slotted(*) .button-outline { +:host-context(ion-toolbar:not(.ion-color))::slotted(*) .button-outline:not(.ion-color) { --color: #{var(--ion-toolbar-color, ion-color(primary, base))}; --color-activated: #{var(--ion-toolbar-background, ion-color(primary, contrast))}; --color-focused: #{var(--ion-toolbar-color, ion-color(primary, base))}; --border-color: #{var(--ion-toolbar-color, ion-color(primary, base))}; - --background-activated: #{var(--ion-toolbar-color, ion-color(primary, base))}; + --background-focused: #{var(--ion-toolbar-color, ion-color(primary, base))}; } // iOS Toolbar Button Solid // -------------------------------------------------- -:host-context(ion-toolbar:not(.ion-color))::slotted(*) .button-solid { +:host-context(ion-toolbar:not(.ion-color))::slotted(*) .button-solid:not(.ion-color) { --color: #{$toolbar-ios-background}; --color-activated: #{$toolbar-ios-background}; --color-focused: #{$toolbar-ios-background}; --background: #{var(--ion-toolbar-color, ion-color(primary, base))}; - --background-activated: #{var(--ion-toolbar-color-activated, ion-color(primary, shade))}; - --background-focused: #{var(--ion-toolbar-color-activated, ion-color(primary, shade))}; + --background-hover: #{var(--ion-toolbar-background, ion-color(primary, contrast))}; + --background-hover-opacity: 0.1; + --background-focused: #000; + --background-focused-opacity: .12; + --background-activated: #000; + --background-activated-opacity: .12; } diff --git a/core/src/components/buttons/buttons.md.scss b/core/src/components/buttons/buttons.md.scss index e9d994f24c..211448ef68 100644 --- a/core/src/components/buttons/buttons.md.scss +++ b/core/src/components/buttons/buttons.md.scss @@ -31,15 +31,16 @@ --color: initial; --color-focused: #{current-color(contrast)}; --color-hover: #{current-color(contrast)}; - --background-hover: #{current-color(contrast, .08)}; - --background-focused: #{current-color(contrast, .24)}; + --background-activated: transparent; + --background-focused: #{current-color(contrast)}; + --background-hover: #{current-color(contrast)}; } :host-context(.ion-color)::slotted(*) .button-solid { --background: #{current-color(contrast)}; - --background-activated: #{current-color(contrast)}; + --background-activated: transparent; --background-focused: #{current-color(shade)}; - --background-hover: #{current-color(tint)}; + --background-hover: #{current-color(base)}; --color: #{current-color(base)}; --color-focused: #{current-color(base)}; --color-hover: #{current-color(base)}; @@ -68,7 +69,7 @@ ::slotted(*) .button { - --background-hover: rgba(66, 66, 66, 0.08); + --background-hover: currentColor; } // Material Design Toolbar Solid Button @@ -78,9 +79,8 @@ --color: #{$toolbar-md-background}; --color-activated: #{$toolbar-md-background}; --background: #{$toolbar-md-color}; - --background-activated: #{$toolbar-md-color}; - --background-focused: #{$toolbar-md-color-activated}; - --background-hover: rgba(66, 66, 66, 0.92); + --background-activated: transparent; + --background-focused: currentColor; } @@ -93,8 +93,9 @@ --color-focused: #{$toolbar-md-color}; --background: transparent; --background-activated: transparent; + --background-focused: currentColor; + --background-hover: currentColor; --border-color: #{$toolbar-md-color}; - --background-focused: rgba(66, 66, 66, 0.1); } @@ -106,7 +107,9 @@ --color-focused: #{$toolbar-md-color}; --color-activated: currentColor; --background: transparent; - --background-focused: rgba(66, 66, 66, 0.1); + --background-activated: transparent; + --background-focused: currentColor; + --background-hover: currentColor; } diff --git a/core/src/components/card/card.ios.scss b/core/src/components/card/card.ios.scss index e5ea78624d..64151b7260 100755 --- a/core/src/components/card/card.ios.scss +++ b/core/src/components/card/card.ios.scss @@ -20,6 +20,6 @@ box-shadow: $card-ios-box-shadow; } -:host(.activated) { +:host(.ion-activated) { transform: #{$card-ios-transform-activated}; } \ No newline at end of file diff --git a/core/src/components/card/readme.md b/core/src/components/card/readme.md index da51fdf51b..224ede7925 100644 --- a/core/src/components/card/readme.md +++ b/core/src/components/card/readme.md @@ -40,9 +40,9 @@ sub-components to reflect this. Please see `ion-card-content`, - + - Card Link Item 1 .activated + Card Link Item 1 activated @@ -50,9 +50,9 @@ sub-components to reflect this. Please see `ion-card-content`, Card Link Item 2 - + - Card Button Item 1 .activated + Card Button Item 1 activated @@ -97,9 +97,9 @@ export const CardExample: React.FC = () => ( - + - Card Link Item 1 .activated + Card Link Item 1 activated @@ -107,9 +107,9 @@ export const CardExample: React.FC = () => ( Card Link Item 2 - + - Card Button Item 1 .activated + Card Button Item 1 activated @@ -152,9 +152,9 @@ export const CardExample: React.FC = () => ( - + - Card Link Item 1 .activated + Card Link Item 1 activated @@ -162,9 +162,9 @@ export const CardExample: React.FC = () => ( Card Link Item 2 - + - Card Button Item 1 .activated + Card Button Item 1 activated diff --git a/core/src/components/card/test/basic/index.html b/core/src/components/card/test/basic/index.html index a6904804f4..5b4f57d7d7 100644 --- a/core/src/components/card/test/basic/index.html +++ b/core/src/components/card/test/basic/index.html @@ -85,9 +85,9 @@ - + - Link Item .activated + Link Item activated More @@ -97,9 +97,9 @@ More - + - Button Item .activated + Button Item activated More diff --git a/core/src/components/card/test/translucent/index.html b/core/src/components/card/test/translucent/index.html index f4d4704c37..6bafc454b6 100644 --- a/core/src/components/card/test/translucent/index.html +++ b/core/src/components/card/test/translucent/index.html @@ -115,7 +115,7 @@ - + Activated diff --git a/core/src/components/card/usage/angular.md b/core/src/components/card/usage/angular.md index 094bfc7f87..d867acb0d0 100644 --- a/core/src/components/card/usage/angular.md +++ b/core/src/components/card/usage/angular.md @@ -25,9 +25,9 @@ - + - Card Link Item 1 .activated + Card Link Item 1 activated @@ -35,9 +35,9 @@ Card Link Item 2 - + - Card Button Item 1 .activated + Card Button Item 1 activated diff --git a/core/src/components/card/usage/javascript.md b/core/src/components/card/usage/javascript.md index 094bfc7f87..d867acb0d0 100644 --- a/core/src/components/card/usage/javascript.md +++ b/core/src/components/card/usage/javascript.md @@ -25,9 +25,9 @@ - + - Card Link Item 1 .activated + Card Link Item 1 activated @@ -35,9 +35,9 @@ Card Link Item 2 - + - Card Button Item 1 .activated + Card Button Item 1 activated diff --git a/core/src/components/card/usage/react.md b/core/src/components/card/usage/react.md index 3af620c155..2c0b112413 100644 --- a/core/src/components/card/usage/react.md +++ b/core/src/components/card/usage/react.md @@ -30,9 +30,9 @@ export const CardExample: React.FC = () => ( - + - Card Link Item 1 .activated + Card Link Item 1 activated @@ -40,9 +40,9 @@ export const CardExample: React.FC = () => ( Card Link Item 2 - + - Card Button Item 1 .activated + Card Button Item 1 activated diff --git a/core/src/components/card/usage/vue.md b/core/src/components/card/usage/vue.md index 2e52aa4333..0e5aa1575b 100644 --- a/core/src/components/card/usage/vue.md +++ b/core/src/components/card/usage/vue.md @@ -26,9 +26,9 @@ - + - Card Link Item 1 .activated + Card Link Item 1 activated @@ -36,9 +36,9 @@ Card Link Item 2 - + - Card Button Item 1 .activated + Card Button Item 1 activated diff --git a/core/src/components/chip/chip.scss b/core/src/components/chip/chip.scss index 980b6e5ac2..0a3a8377ca 100644 --- a/core/src/components/chip/chip.scss +++ b/core/src/components/chip/chip.scss @@ -50,7 +50,7 @@ background: current-color(base, .12); } -:host(.ion-color.activated) { +:host(.ion-color.ion-activated) { background: current-color(base, .16); } @@ -78,7 +78,7 @@ background: rgba(0, 0, 0, .04); } -:host(.chip-outline.activated:not(.ion-color)) { +:host(.chip-outline.ion-activated:not(.ion-color)) { background: rgba(0, 0, 0, .08); } @@ -135,7 +135,7 @@ // Chip: Activated // --------------------------------------------- -:host(.activated) { +:host(.ion-activated) { --background: #{rgba($text-color-rgb, .20)}; } diff --git a/core/src/components/chip/test/basic/index.html b/core/src/components/chip/test/basic/index.html index e0c7da0155..a6faa33263 100644 --- a/core/src/components/chip/test/basic/index.html +++ b/core/src/components/chip/test/basic/index.html @@ -4,12 +4,14 @@ Chip - Basic - + - + + @@ -22,77 +24,81 @@ -

Basic Chips

- - Default - - - Border Radius - - - - With Icon - - - - - - With Avatar - - - - - - With Icon and Avatar - - +

Basic Chips

+ + Default + + + Border Radius + + + + With Icon + + + + + + With Avatar + + + + + + With Icon and Avatar + + -

Color Chips

- - Primary - - - Danger - - - - Tertiary with Icon - - - - - - Primary with Avatar - - - Success with Icon - - +

Color Chips

+ + Primary + + + Danger + + + + Tertiary with Icon + + + + + + Primary with Avatar + + + Success with Icon + + -

Outline Chips

- - Outline - - - Danger Outline - - - - Secondary Outline with Icon - - - Primary Outline with Avatar - - - - - - - Outline with Icon and Avatar - - +

Outline Chips

+ + Outline + + + Danger Outline + + + + Secondary Outline with Icon + + + Primary Outline with Avatar + + + + + + + Outline with Icon and Avatar + + -
+
diff --git a/core/src/components/chip/test/states/e2e.ts b/core/src/components/chip/test/states/e2e.ts new file mode 100644 index 0000000000..b410c5869a --- /dev/null +++ b/core/src/components/chip/test/states/e2e.ts @@ -0,0 +1,10 @@ +import { newE2EPage } from '@stencil/core/testing'; + +test('chip: states', async () => { + const page = await newE2EPage({ + url: '/src/components/chip/test/states?ionic:_testing=true' + }); + + const compare = await page.compareScreenshot(); + expect(compare).toMatchScreenshot(); +}); diff --git a/core/src/components/chip/test/states/index.html b/core/src/components/chip/test/states/index.html new file mode 100644 index 0000000000..7c47e2d3cf --- /dev/null +++ b/core/src/components/chip/test/states/index.html @@ -0,0 +1,285 @@ + + + + + + Chip - States + + + + + + + + + + + +

Default

+

+ + Default + + + Border Radius + + + + With Icon + + + + + + With Avatar + + + + + + With Icon and Avatar + + +

+

+ + Default + + + Border Radius + + + + With Icon + + + + + + With Avatar + + + + + + With Icon and Avatar + + +

+ +

Colors

+

+ + Primary + + + Secondary + + + + Tertiary with Icon + + + + + + Success with Avatar + + + Warning with Icon + + + + Danger + + + Light + + + Medium + + + Dark + +

+

+ + Primary + + + Secondary + + + + Tertiary with Icon + + + + + + Success with Avatar + + + Warning with Icon + + + + Danger + + + Light + + + Medium + + + Dark + +

+ +

Outline

+ +

+ + Outline + + + Danger Outline + + + + Secondary Outline with Icon + + + Primary Outline with Avatar + + + + + + + Outline with Icon and Avatar + + +

+

+ + Outline + + + Danger Outline + + + + Secondary Outline with Icon + + + Primary Outline with Avatar + + + + + + + Outline with Icon and Avatar + + +

+ +

Custom

+ + +

+ + + + + + +

+ + +

+ + + + + + + + + + + + +

+
+
+ + + + + + + diff --git a/core/src/components/fab-button/fab-button.ios.scss b/core/src/components/fab-button/fab-button.ios.scss index 178b7a892b..a713815b35 100755 --- a/core/src/components/fab-button/fab-button.ios.scss +++ b/core/src/components/fab-button/fab-button.ios.scss @@ -7,7 +7,11 @@ :host { --background: #{$fab-ios-background-color}; --background-activated: #{$fab-ios-background-color-activated}; - --background-focused: var(--background-activated); + --background-focused: #{ion-color(primary, shade)}; + --background-hover: #{ion-color(primary, tint)}; + --background-activated-opacity: 1; + --background-focused-opacity: 1; + --background-hover-opacity: 1; --color: #{$fab-ios-text-color}; --color-activated: #{$fab-ios-text-color}; --color-focused: var(--color-activated); @@ -15,7 +19,7 @@ --transition: #{$fab-ios-transition}; } -:host(.activated) { +:host(.ion-activated) { --box-shadow: #{$fab-ios-box-shadow-activated}; --transform: #{$fab-ios-transform}; --transition: #{$fab-ios-transition-activated}; @@ -46,6 +50,34 @@ } +// FAB Button: Color +// -------------------------------------------------- + +:host(.ion-color.ion-focused) .button-native::after { + background: #{current-color(shade)}; +} + +// Focused/Activated Button with Color +:host(.ion-color.ion-focused) .button-native, +:host(.ion-color.ion-activated) .button-native { + color: #{current-color(contrast)}; + + &::after { + background: #{current-color(shade)}; + } +} + +@media (any-hover: hover) { + :host(.ion-color:hover) .button-native { + color: #{current-color(contrast)}; + + &::after { + background: #{current-color(tint)}; + } + } +} + + // Translucent FAB buttons // -------------------------------------------------- @@ -79,7 +111,7 @@ } :host(.ion-color.ion-focused.fab-button-translucent) .button-native, - :host(.ion-color.activated.fab-button-translucent) .button-native { + :host(.ion-color.ion-activated.fab-button-translucent) .button-native { background: #{current-color(base)}; } } \ No newline at end of file diff --git a/core/src/components/fab-button/fab-button.md.scss b/core/src/components/fab-button/fab-button.md.scss index ebdca4507e..6da2493062 100755 --- a/core/src/components/fab-button/fab-button.md.scss +++ b/core/src/components/fab-button/fab-button.md.scss @@ -6,8 +6,12 @@ :host { --background: #{$fab-md-background-color}; - --background-activated: var(--background); - --background-focused: var(--background-activated); + --background-activated: transparent; + --background-focused: currentColor; + --background-hover: currentColor; + --background-activated-opacity: 0; + --background-focused-opacity: .24; + --background-hover-opacity: .08; --color: #{$fab-md-text-color}; --color-activated: #{$fab-md-text-color}; --color-focused: var(--color-activated); @@ -21,7 +25,7 @@ }; } -:host(.activated) { +:host(.ion-activated) { --box-shadow: #{$fab-md-box-shadow-activated}; } @@ -39,11 +43,41 @@ --color-activated: #{$fab-md-list-button-text-color}; --color-focused: var(--color-activated); --background: #{$fab-md-list-button-background-color}; - --background-activated: #{$fab-md-list-button-background-color-activated}; - --background-focused: var(--background-activated); + --background-activated: transparent; + --background-focused: #{$fab-md-list-button-background-color-activated}; --background-hover: #{$fab-md-list-button-background-color-hover}; } :host(.fab-button-in-list) ::slotted(ion-icon) { font-size: $fab-md-list-button-icon-font-size; } + + +// FAB Button: Color +// -------------------------------------------------- + +// Focused Button with Color +:host(.ion-color.ion-focused) .button-native { + color: #{current-color(contrast)}; + + &::after { + background: #{current-color(contrast)}; + } +} +:host(.ion-color.ion-activated) .button-native { + color: #{current-color(contrast)}; + + &::after { + background: transparent; + } +} + +@media (any-hover: hover) { + :host(.ion-color:hover) .button-native { + color: #{current-color(contrast)}; + + &::after { + background: #{current-color(contrast)}; + } + } +} \ No newline at end of file diff --git a/core/src/components/fab-button/fab-button.md.vars.scss b/core/src/components/fab-button/fab-button.md.vars.scss index 2c936f002c..5c5e6c2d52 100755 --- a/core/src/components/fab-button/fab-button.md.vars.scss +++ b/core/src/components/fab-button/fab-button.md.vars.scss @@ -13,7 +13,7 @@ $fab-md-box-shadow-activated: 0 7px 8px -4px rgba(0, 0, 0, . $fab-md-background-color: ion-color(primary, base) !default; /// @prop - Background color of the activated button -$fab-md-background-color-activated: ion-color(primary, shade) !default; +$fab-md-background-color-activated: ion-color(primary, contrast) !default; /// @prop - Text color of the button $fab-md-text-color: ion-color(primary, contrast) !default; diff --git a/core/src/components/fab-button/fab-button.scss b/core/src/components/fab-button/fab-button.scss index 4ca8ec024c..6edfa82862 100755 --- a/core/src/components/fab-button/fab-button.scss +++ b/core/src/components/fab-button/fab-button.scss @@ -6,9 +6,12 @@ :host { /** * @prop --background: Background of the button - * @prop --background-activated: Background of the button when pressed + * @prop --background-activated: Background of the button when pressed. Note: setting this will interfere with the Material Design ripple. + * @prop --background-activated-opacity: Opacity of the button background when pressed * @prop --background-focused: Background of the button when focused with the tab key + * @prop --background-focused-opacity: Opacity of the button background when focused with the tab key * @prop --background-hover: Background of the button on hover + * @prop --background-hover-opacity: Opacity of the button background on hover * * @prop --color: Text color of the button * @prop --color-activated: Text color of the button when pressed @@ -32,7 +35,8 @@ * @prop --padding-start: Left padding if direction is left-to-right, and right padding if direction is right-to-left of the button */ --color-hover: #{var(--color)}; - --background-hover: #{ion-color(primary, tint)}; + --background-hover: #{ion-color(primary, contrast)}; + --background-hover-opacity: .08; --transition: background-color, opacity 100ms linear; --ripple-color: currentColor; --border-radius: #{$fab-border-radius}; @@ -101,6 +105,10 @@ line-height: 1; } +.button-native::after { + @include button-state(); +} + .button-inner { @include position(0, 0, null, 0); @@ -116,15 +124,8 @@ transition: all ease-in-out 300ms; transition-property: transform, opacity; -} - -// FAB Button: Color -// -------------------------------------------------- - -:host(.ion-color) .button-native { - background: #{current-color(base)}; - color: #{current-color(contrast)}; + z-index: 1; } @@ -132,13 +133,8 @@ // -------------------------------------------------- :host(.fab-button-disabled) { - opacity: .5; - - pointer-events: none; -} - -:host(.fab-button-disabled) .button-native { cursor: default; + opacity: .5; pointer-events: none; } @@ -148,41 +144,42 @@ @media (any-hover: hover) { :host(:hover) .button-native { - background: var(--background-hover); color: var(--color-hover); - } - :host(.ion-color:hover) .button-native { - background: #{current-color(tint)}; - color: #{current-color(contrast)}; + &::after { + background: var(--background-hover); + + opacity: var(--background-hover-opacity); + } } } + // FAB Button: Focused // -------------------------------------------------- :host(.ion-focused) .button-native { - background: var(--background-focused); color: var(--color-focused); + + &::after { + background: var(--background-focused); + + opacity: var(--background-focused-opacity); + } } -:host(.ion-color.ion-focused) .button-native { - background: #{current-color(shade)}; -} // FAB Button: Activated // -------------------------------------------------- -:host(.activated) .button-native { - background: var(--background-activated); +:host(.ion-activated) .button-native { color: var(--color-activated); -} -// Focused/Activated Button with Color -:host(.ion-color.ion-focused) .button-native, -:host(.ion-color.activated) .button-native { - background: #{current-color(shade)}; - color: #{current-color(contrast)}; + &::after { + background: var(--background-activated); + + opacity: var(--background-activated-opacity); + } } @@ -252,4 +249,13 @@ ion-ripple-effect { :host(.fab-button-translucent) .button-native { backdrop-filter: var(--backdrop-filter); } -} \ No newline at end of file +} + + +// FAB Button: Color +// -------------------------------------------------- + +:host(.ion-color) .button-native { + background: #{current-color(base)}; + color: #{current-color(contrast)}; +} diff --git a/core/src/components/fab-button/readme.md b/core/src/components/fab-button/readme.md index e6e1d76701..2d2e5acc7d 100644 --- a/core/src/components/fab-button/readme.md +++ b/core/src/components/fab-button/readme.md @@ -125,27 +125,30 @@ export const FabButtonExample: React.FC = () => ( ## CSS Custom Properties -| Name | Description | -| ------------------------ | --------------------------------------------------------------------------------------------------------- | -| `--background` | Background of the button | -| `--background-activated` | Background of the button when pressed | -| `--background-focused` | Background of the button when focused with the tab key | -| `--background-hover` | Background of the button on hover | -| `--border-color` | Border color of the button | -| `--border-radius` | Border radius of the button | -| `--border-style` | Border style of the button | -| `--border-width` | Border width of the button | -| `--box-shadow` | Box shadow of the button | -| `--color` | Text color of the button | -| `--color-activated` | Text color of the button when pressed | -| `--color-focused` | Text color of the button when focused with the tab key | -| `--color-hover` | Text color of the button on hover | -| `--padding-bottom` | Bottom padding of the button | -| `--padding-end` | Right padding if direction is left-to-right, and left padding if direction is right-to-left of the button | -| `--padding-start` | Left padding if direction is left-to-right, and right padding if direction is right-to-left of the button | -| `--padding-top` | Top padding of the button | -| `--ripple-color` | Color of the button ripple effect | -| `--transition` | Transition of the button | +| Name | Description | +| -------------------------------- | --------------------------------------------------------------------------------------------------------- | +| `--background` | Background of the button | +| `--background-activated` | Background of the button when pressed. Note: setting this will interfere with the Material Design ripple. | +| `--background-activated-opacity` | Opacity of the button background when pressed | +| `--background-focused` | Background of the button when focused with the tab key | +| `--background-focused-opacity` | Opacity of the button background when focused with the tab key | +| `--background-hover` | Background of the button on hover | +| `--background-hover-opacity` | Opacity of the button background on hover | +| `--border-color` | Border color of the button | +| `--border-radius` | Border radius of the button | +| `--border-style` | Border style of the button | +| `--border-width` | Border width of the button | +| `--box-shadow` | Box shadow of the button | +| `--color` | Text color of the button | +| `--color-activated` | Text color of the button when pressed | +| `--color-focused` | Text color of the button when focused with the tab key | +| `--color-hover` | Text color of the button on hover | +| `--padding-bottom` | Bottom padding of the button | +| `--padding-end` | Right padding if direction is left-to-right, and left padding if direction is right-to-left of the button | +| `--padding-start` | Left padding if direction is left-to-right, and right padding if direction is right-to-left of the button | +| `--padding-top` | Top padding of the button | +| `--ripple-color` | Color of the button ripple effect | +| `--transition` | Transition of the button | ## Dependencies diff --git a/core/src/components/fab-button/test/standalone/index.html b/core/src/components/fab-button/test/standalone/index.html index 7730f11463..e4b6f45a23 100644 --- a/core/src/components/fab-button/test/standalone/index.html +++ b/core/src/components/fab-button/test/standalone/index.html @@ -21,8 +21,8 @@ In List - - + +

Colors

@@ -38,15 +38,15 @@

- - - - - - - - - + + + + + + + + +

Custom

@@ -56,20 +56,20 @@ - + White - White + White - + - + Border - Border + Border - + + + + diff --git a/core/src/components/item-option/item-option.ios.scss b/core/src/components/item-option/item-option.ios.scss index 6249ee7985..2629d9b119 100644 --- a/core/src/components/item-option/item-option.ios.scss +++ b/core/src/components/item-option/item-option.ios.scss @@ -8,10 +8,10 @@ font-size: $item-option-button-ios-font-size; } -:host(.activated) { +:host(.ion-activated) { background: ion-color(primary, shade); } -:host(.ion-color.activated) { +:host(.ion-color.ion-activated) { background: current-color(shade); } diff --git a/core/src/components/item-sliding/test/basic/index.html b/core/src/components/item-sliding/test/basic/index.html index 813ab055a7..f79f14900f 100644 --- a/core/src/components/item-sliding/test/basic/index.html +++ b/core/src/components/item-sliding/test/basic/index.html @@ -161,7 +161,7 @@ - +

LEFT side - no icons

I think I figured out how to get more Mountain Dew

diff --git a/core/src/components/item/item.ios.scss b/core/src/components/item/item.ios.scss index 6e80302802..87235cbddf 100644 --- a/core/src/components/item/item.ios.scss +++ b/core/src/components/item/item.ios.scss @@ -6,14 +6,17 @@ :host { --min-height: #{$item-ios-min-height}; - --transition: background-color 200ms linear; + --transition: background-color 200ms linear, opacity 200ms linear; --padding-start: #{$item-ios-padding-start}; --inner-padding-end: #{$item-ios-padding-end / 2}; --inner-border-width: #{0px 0px $item-ios-border-bottom-width 0px}; --background: #{$item-ios-background}; - --background-activated: #{$item-ios-background-activated}; - --background-focused: #{$item-ios-background-focused}; - --background-hover: #{$item-ios-background-hover}; + --background-activated: #000; + --background-focused: #000; + --background-hover: currentColor; + --background-activated-opacity: .12; + --background-focused-opacity: .15; + --background-hover-opacity: .04; --border-color: #{$item-ios-border-bottom-color}; --color: #{$item-ios-color}; --highlight-height: 0; @@ -25,27 +28,24 @@ } -// iOS Activated +// iOS Item: States // -------------------------------------------------- -:host(.activated) { +:host(.ion-activated) { --transition: none; } -:host(.ion-color.activated) .item-native { - background: current-color(shade); - color: current-color(contrast); +:host(.ion-color.ion-focused) .item-native::after { + background: #000; + + opacity: .15; } -@media (any-hover: hover) { - :host(.activated.ion-activatable:hover) .item-native { - background: var(--background-activated); - color: var(--color-activated); - } +:host(.ion-color.ion-activated) .item-native { + &::after { + background: #000; - :host(.activated.ion-color.ion-activatable:hover) .item-native { - background: #{current-color(shade)}; - color: #{current-color(contrast)}; + opacity: .12; } } diff --git a/core/src/components/item/item.md.scss b/core/src/components/item/item.md.scss index 55dc5f5cd3..643001a9bb 100644 --- a/core/src/components/item/item.md.scss +++ b/core/src/components/item/item.md.scss @@ -8,12 +8,15 @@ :host { --min-height: #{$item-md-min-height}; --background: #{$item-md-background}; - --background-activated: var(--background); - --background-focused: #{$item-md-background-focused}; - --background-hover: #{$item-md-background-hover}; + --background-activated: transparent; + --background-focused: currentColor; + --background-hover: currentColor; + --background-activated-opacity: 0; + --background-focused-opacity: .12; + --background-hover-opacity: .04; --border-color: #{$item-md-border-bottom-color}; --color: #{$item-md-color}; - --transition: background-color 300ms cubic-bezier(.4, 0, .2, 1); + --transition: opacity 15ms linear, background-color 15ms linear; --padding-start: #{$item-md-padding-start}; --color: #{$item-md-color}; --border-color: #{$item-md-border-bottom-color}; @@ -31,22 +34,13 @@ } -// Material Design Item: Focused & Activated +// Material Design Item: States // -------------------------------------------------- -:host(.ion-focused.activated) .item-native { - background: var(--background-focused); - color: var(--color-focused); -} - -:host(.ion-color.activated) .item-native { - background: current-color(base); - color: current-color(contrast); -} - -:host(.ion-color.ion-focused.activated) .item-native { - background: current-color(shade); - color: current-color(contrast); +:host(.ion-color.ion-activated) .item-native { + &::after { + background: transparent; + } } diff --git a/core/src/components/item/item.scss b/core/src/components/item/item.scss index e9226e1679..3a6aae4350 100644 --- a/core/src/components/item/item.scss +++ b/core/src/components/item/item.scss @@ -6,9 +6,12 @@ :host { /** * @prop --background: Background of the item - * @prop --background-activated: Background of the item when pressed + * @prop --background-activated: Background of the item when pressed. Note: setting this will interfere with the Material Design ripple. + * @prop --background-activated-opacity: Opacity of the item background when pressed * @prop --background-focused: Background of the item when focused with the tab key + * @prop --background-focused-opacity: Opacity of the item background when focused with the tab key * @prop --background-hover: Background of the item on hover + * @prop --background-hover-opacity: Opacity of the background of the item on hover * * @prop --border-color: Color of the item border * @prop --border-radius: Radius of the item border @@ -25,8 +28,8 @@ * @prop --detail-icon-color: Color of the item detail icon * @prop --detail-icon-opacity: Opacity of the item detail icon * @prop --detail-icon-font-size: Font size of the item detail icon - * @prop --inner-border-width: Width of the item inner border * + * @prop --inner-border-width: Width of the item inner border * @prop --inner-box-shadow: Box shadow of the item inner * @prop --inner-padding-top: Top padding of the item inner * @prop --inner-padding-end: Right padding if direction is left-to-right, and left padding if direction is right-to-left of the item inner @@ -107,17 +110,43 @@ } +// Item: Activated +// -------------------------------------------------- + +:host(.ion-activated) .item-native { + color: var(--color-activated); + + &::after { + background: var(--background-activated); + + opacity: var(--background-activated-opacity); + } +} + +:host(.ion-color.ion-activated) .item-native { + color: current-color(contrast); +} + + // Item: Focused // -------------------------------------------------- :host(.ion-focused) .item-native { - background: var(--background-focused); color: var(--color-focused); + + &::after { + background: var(--background-focused); + + opacity: var(--background-focused-opacity); + } } :host(.ion-color.ion-focused) .item-native { - background: current-color(shade); color: current-color(contrast); + + &::after { + background: current-color(contrast); + } } @@ -126,26 +155,24 @@ @media (any-hover: hover) { :host(.ion-activatable:hover) .item-native { - background: var(--background-hover); color: var(--color-hover); + + &::after { + background: var(--background-hover); + + opacity: var(--background-hover-opacity); + } } :host(.ion-color.ion-activatable:hover) .item-native { - background: #{current-color(tint)}; color: #{current-color(contrast)}; + + &::after { + background: #{current-color(contrast)}; + } } } - -// Item: Activated -// -------------------------------------------------- - -:host(.activated) .item-native { - background: var(--background-activated); - color: var(--color-activated); -} - - // Item: Disabled // -------------------------------------------------- @@ -197,12 +224,22 @@ box-shadow: var(--box-shadow); overflow: inherit; box-sizing: border-box; + + z-index: 1; } .item-native::-moz-focus-inner { border: 0; } +.item-native::after { + @include button-state(); + + transition: var(--transition); + + z-index: -1; +} + button, a { cursor: pointer; user-select: none; diff --git a/core/src/components/item/readme.md b/core/src/components/item/readme.md index 41ef7c5bd4..5330fd32cb 100644 --- a/core/src/components/item/readme.md +++ b/core/src/components/item/readme.md @@ -1392,41 +1392,44 @@ Item Inputs ## CSS Custom Properties -| Name | Description | -| --------------------------- | ------------------------------------------------------------------------------------------------------------- | -| `--background` | Background of the item | -| `--background-activated` | Background of the item when pressed | -| `--background-focused` | Background of the item when focused with the tab key | -| `--background-hover` | Background of the item on hover | -| `--border-color` | Color of the item border | -| `--border-radius` | Radius of the item border | -| `--border-style` | Style of the item border | -| `--border-width` | Width of the item border | -| `--box-shadow` | Box shadow of the item | -| `--color` | Color of the item | -| `--color-activated` | Color of the item when pressed | -| `--color-focused` | Color of the item when focused with the tab key | -| `--color-hover` | Color of the item on hover | -| `--detail-icon-color` | Color of the item detail icon | -| `--detail-icon-font-size` | Font size of the item detail icon | -| `--detail-icon-opacity` | Opacity of the item detail icon | -| `--highlight-color-focused` | The color of the highlight on the item when focused | -| `--highlight-color-invalid` | The color of the highlight on the item when invalid | -| `--highlight-color-valid` | The color of the highlight on the item when valid | -| `--highlight-height` | The height of the highlight on the item | -| `--inner-border-width` | Width of the item inner border | -| `--inner-box-shadow` | Box shadow of the item inner | -| `--inner-padding-bottom` | Bottom padding of the item inner | -| `--inner-padding-end` | Right padding if direction is left-to-right, and left padding if direction is right-to-left of the item inner | -| `--inner-padding-start` | Left padding if direction is left-to-right, and right padding if direction is right-to-left of the item inner | -| `--inner-padding-top` | Top padding of the item inner | -| `--min-height` | Minimum height of the item | -| `--padding-bottom` | Bottom padding of the item | -| `--padding-end` | Right padding if direction is left-to-right, and left padding if direction is right-to-left of the item | -| `--padding-start` | Left padding if direction is left-to-right, and right padding if direction is right-to-left of the item | -| `--padding-top` | Top padding of the item | -| `--ripple-color` | Color of the item ripple effect | -| `--transition` | Transition of the item | +| Name | Description | +| -------------------------------- | ------------------------------------------------------------------------------------------------------------- | +| `--background` | Background of the item | +| `--background-activated` | Background of the item when pressed. Note: setting this will interfere with the Material Design ripple. | +| `--background-activated-opacity` | Opacity of the item background when pressed | +| `--background-focused` | Background of the item when focused with the tab key | +| `--background-focused-opacity` | Opacity of the item background when focused with the tab key | +| `--background-hover` | Background of the item on hover | +| `--background-hover-opacity` | Opacity of the background of the item on hover | +| `--border-color` | Color of the item border | +| `--border-radius` | Radius of the item border | +| `--border-style` | Style of the item border | +| `--border-width` | Width of the item border | +| `--box-shadow` | Box shadow of the item | +| `--color` | Color of the item | +| `--color-activated` | Color of the item when pressed | +| `--color-focused` | Color of the item when focused with the tab key | +| `--color-hover` | Color of the item on hover | +| `--detail-icon-color` | Color of the item detail icon | +| `--detail-icon-font-size` | Font size of the item detail icon | +| `--detail-icon-opacity` | Opacity of the item detail icon | +| `--highlight-color-focused` | The color of the highlight on the item when focused | +| `--highlight-color-invalid` | The color of the highlight on the item when invalid | +| `--highlight-color-valid` | The color of the highlight on the item when valid | +| `--highlight-height` | The height of the highlight on the item | +| `--inner-border-width` | Width of the item inner border | +| `--inner-box-shadow` | Box shadow of the item inner | +| `--inner-padding-bottom` | Bottom padding of the item inner | +| `--inner-padding-end` | Right padding if direction is left-to-right, and left padding if direction is right-to-left of the item inner | +| `--inner-padding-start` | Left padding if direction is left-to-right, and right padding if direction is right-to-left of the item inner | +| `--inner-padding-top` | Top padding of the item inner | +| `--min-height` | Minimum height of the item | +| `--padding-bottom` | Bottom padding of the item | +| `--padding-end` | Right padding if direction is left-to-right, and left padding if direction is right-to-left of the item | +| `--padding-start` | Left padding if direction is left-to-right, and right padding if direction is right-to-left of the item | +| `--padding-top` | Top padding of the item | +| `--ripple-color` | Color of the item ripple effect | +| `--transition` | Transition of the item | ## Dependencies diff --git a/core/src/components/item/test/buttons/index.html b/core/src/components/item/test/buttons/index.html index b4ac9e209e..fd208d1726 100644 --- a/core/src/components/item/test/buttons/index.html +++ b/core/src/components/item/test/buttons/index.html @@ -25,10 +25,14 @@ a[ion-item]
- + a[ion-item].activated + + custom hover + + a[ion-item] secondary @@ -41,7 +45,7 @@ button[ion-item] type="submit" - + button[ion-item].activated @@ -149,6 +153,12 @@ .custom { --ripple-color: pink; } + + .custom-hover { + --background-hover: green; + --background-hover-opacity: 1; + --color-hover: purple; + } + + + + + + + + + Item - States + + + + + + ion-item[href] + + + + ion-item[href] focused + + + + ion-item[href] activated + + + + ion-item[button] + + + + ion-item[button] focused + + + + ion-item[button] border-radius focused + + + + ion-item[button] activated + + + + ion-item[href] + + + + ion-item[href] focused + + + + ion-item[href] activated + + + + ion-item[button] + + + + ion-item[button] focused + + + + ion-item[button] activated + + + + ion-item[href] + + + + ion-item[href] focused + + + + ion-item[href] activated + + + + + + + + + + diff --git a/core/src/components/menu-button/menu-button.ios.scss b/core/src/components/menu-button/menu-button.ios.scss index e1efb0f462..63927ab097 100644 --- a/core/src/components/menu-button/menu-button.ios.scss +++ b/core/src/components/menu-button/menu-button.ios.scss @@ -1,10 +1,12 @@ +@import "../../themes/ionic.globals.ios"; @import "./menu-button"; // iOS Menu Button // -------------------------------------------------- :host { - --background-focused: #{ion-color(primary, base, .1)}; + --background-focused: currentColor; + --background-focused-opacity: .1; --border-radius: 4px; --color: #{ion-color(primary, base)}; --padding-start: 5px; @@ -15,20 +17,20 @@ font-size: 31px; } -:host(.activated) { + +// Menu Button: Activated +// -------------------------------------------------- + +:host(.ion-activated) { opacity: .4; } + +// Menu Button: Hover +// -------------------------------------------------- + @media (any-hover: hover) { :host(:hover) { opacity: .6; } } - - -// Menu Button Color: Focused -// -------------------------------------------------- - -:host(.ion-color.ion-focused) .button-native { - background: #{current-color(base, .1)}; -} \ No newline at end of file diff --git a/core/src/components/menu-button/menu-button.md.scss b/core/src/components/menu-button/menu-button.md.scss index 9a2267c531..a28a2ffdd8 100644 --- a/core/src/components/menu-button/menu-button.md.scss +++ b/core/src/components/menu-button/menu-button.md.scss @@ -1,11 +1,14 @@ +@import "../../themes/ionic.globals.md"; @import "./menu-button"; // MD Menu Button // -------------------------------------------------- :host { - --background-focused: rgba(66, 66, 66, 0.24); - --background-hover: rgba(66, 66, 66, 0.08); + --background-focused: currentColor; + --background-focused-opacity: .12; + --background-hover: currentColor; + --background-hover-opacity: .04; --border-radius: 50%; --color: initial; --padding-start: 8px; @@ -18,20 +21,19 @@ } +// Menu Button Color: Focused +// -------------------------------------------------- + +:host(.ion-color.ion-focused)::after { + background: #{current-color(base)}; +} + + // Menu Button Color: Hover // -------------------------------------------------- @media (any-hover: hover) { - :host(.ion-color:hover) .button-native { - background: #{current-color(base, .08)}; + :host(.ion-color:hover) .button-native::after { + background: #{current-color(base)}; } } - - -// Menu Button Color: Focused -// -------------------------------------------------- - -:host(.ion-color.ion-focused) .button-native { - background: #{current-color(base, .24)}; - color: #{current-color(base)}; -} \ No newline at end of file diff --git a/core/src/components/menu-button/menu-button.scss b/core/src/components/menu-button/menu-button.scss index fcb07eb210..7cfef8a92a 100644 --- a/core/src/components/menu-button/menu-button.scss +++ b/core/src/components/menu-button/menu-button.scss @@ -9,7 +9,9 @@ * * @prop --background: Background of the menu button * @prop --background-hover: Background of the menu button on hover + * @prop --background-hover-opacity: Opacity of the background on hover * @prop --background-focused: Background of the menu button when focused with the tab key + * @prop --background-focused-opacity: Opacity of the menu button background when focused with the tab key * * @prop --color: Color of the menu button * @prop --color-hover: Color of the menu button on hover @@ -21,7 +23,7 @@ * @prop --padding-start: Left padding if direction is left-to-right, and right padding if direction is right-to-left of the button */ --background: transparent; - --color-focused: var(--color); + --color-focused: currentColor; --border-radius: initial; --padding-top: 0; --padding-bottom: 0; @@ -65,11 +67,28 @@ line-height: 1; cursor: pointer; + + overflow: hidden; user-select: none; z-index: 0; appearance: none; } +.button-inner { + display: flex; + position: relative; + + flex-flow: row nowrap; + flex-shrink: 0; + align-items: center; + justify-content: center; + + width: 100%; + height: 100%; + + z-index: 1; +} + ion-icon { @include margin(0); @include padding(0); @@ -94,23 +113,37 @@ ion-icon { } -// Menu Button: Hover -// -------------------------------------------------- - -@media (any-hover: hover) { - :host(:hover) .button-native { - background: var(--background-hover); - color: var(--color-hover); - } -} - - // Menu Button: Focused // -------------------------------------------------- :host(.ion-focused) .button-native { - background: var(--background-focused); color: var(--color-focused); + + &::after { + background: var(--background-focused); + + opacity: var(--background-focused-opacity); + } +} + + +// Menu Button: Hover +// -------------------------------------------------- + +.button-native::after { + @include button-state(); +} + +@media (any-hover: hover) { + :host(:hover) .button-native { + color: var(--color-hover); + + &::after { + background: var(--background-hover); + + opacity: var(--background-hover-opacity, 0); + } + } } @@ -125,7 +158,6 @@ ion-icon { // Menu Button in Toolbar: Global Theming // -------------------------------------------------- -// TODO this will not work in Safari - component is shadow not scoped -:host-context(ion-toolbar:not(.ion-color)) { +:host(.in-toolbar) { color: #{var(--ion-toolbar-color, var(--color))}; } diff --git a/core/src/components/menu-button/menu-button.tsx b/core/src/components/menu-button/menu-button.tsx index 98eddd521a..02caa3aa83 100644 --- a/core/src/components/menu-button/menu-button.tsx +++ b/core/src/components/menu-button/menu-button.tsx @@ -1,11 +1,11 @@ -import { Component, ComponentInterface, Host, Listen, Prop, State, h } from '@stencil/core'; +import { Component, ComponentInterface, Element, Host, Listen, Prop, State, h } from '@stencil/core'; import { config } from '../../global/config'; import { getIonMode } from '../../global/ionic-global'; import { Color } from '../../interface'; import { ButtonInterface } from '../../utils/element-interface'; import { menuController } from '../../utils/menu-controller'; -import { createColorClasses } from '../../utils/theme'; +import { createColorClasses, hostContext } from '../../utils/theme'; import { updateVisibility } from '../menu-toggle/menu-toggle-util'; @Component({ @@ -17,6 +17,7 @@ import { updateVisibility } from '../menu-toggle/menu-toggle-util'; shadow: true }) export class MenuButton implements ComponentInterface, ButtonInterface { + @Element() el!: HTMLIonSegmentElement; @State() visible = false; @@ -84,6 +85,7 @@ export class MenuButton implements ComponentInterface, ButtonInterface { 'button': true, // ion-buttons target .button 'menu-button-hidden': hidden, 'menu-button-disabled': disabled, + 'in-toolbar': hostContext('ion-toolbar', this.el), 'ion-activatable': true, 'ion-focusable': true }} @@ -93,9 +95,11 @@ export class MenuButton implements ComponentInterface, ButtonInterface { disabled={disabled} class="button-native" > - - - + + + + + {mode === 'md' && }
diff --git a/core/src/components/menu-button/readme.md b/core/src/components/menu-button/readme.md index 25761955ab..f83fbdf20a 100644 --- a/core/src/components/menu-button/readme.md +++ b/core/src/components/menu-button/readme.md @@ -19,19 +19,21 @@ Menu Button is component that automatically creates the icon and functionality t ## CSS Custom Properties -| Name | Description | -| ---------------------- | --------------------------------------------------------------------------------------------------------- | -| `--background` | Background of the menu button | -| `--background-focused` | Background of the menu button when focused with the tab key | -| `--background-hover` | Background of the menu button on hover | -| `--border-radius` | Border radius of the menu button | -| `--color` | Color of the menu button | -| `--color-focused` | Color of the menu button when focused with the tab key | -| `--color-hover` | Color of the menu button on hover | -| `--padding-bottom` | Bottom padding of the button | -| `--padding-end` | Right padding if direction is left-to-right, and left padding if direction is right-to-left of the button | -| `--padding-start` | Left padding if direction is left-to-right, and right padding if direction is right-to-left of the button | -| `--padding-top` | Top padding of the button | +| Name | Description | +| ------------------------------ | --------------------------------------------------------------------------------------------------------- | +| `--background` | Background of the menu button | +| `--background-focused` | Background of the menu button when focused with the tab key | +| `--background-focused-opacity` | Opacity of the menu button background when focused with the tab key | +| `--background-hover` | Background of the menu button on hover | +| `--background-hover-opacity` | Opacity of the background on hover | +| `--border-radius` | Border radius of the menu button | +| `--color` | Color of the menu button | +| `--color-focused` | Color of the menu button when focused with the tab key | +| `--color-hover` | Color of the menu button on hover | +| `--padding-bottom` | Bottom padding of the button | +| `--padding-end` | Right padding if direction is left-to-right, and left padding if direction is right-to-left of the button | +| `--padding-start` | Left padding if direction is left-to-right, and right padding if direction is right-to-left of the button | +| `--padding-top` | Top padding of the button | ## Dependencies diff --git a/core/src/components/menu-button/test/basic/index.html b/core/src/components/menu-button/test/basic/index.html index fa4ffbe012..111f4968f8 100644 --- a/core/src/components/menu-button/test/basic/index.html +++ b/core/src/components/menu-button/test/basic/index.html @@ -85,6 +85,14 @@ Success + + + + + + Themed + + @@ -103,13 +111,18 @@ display: inline-block; } + .themed { + --ion-toolbar-background: #222; + --ion-toolbar-color: #ddd; + } + .custom { --color: hotpink; } .custom.md { - --background-hover: rgb(255, 105, 180, .08); - --background-focused: rgb(255, 105, 180, .24); + --background-hover: #ff69b4; + --background-focused: #ff69b4; } .custom-large { diff --git a/core/src/components/picker/picker.ios.scss b/core/src/components/picker/picker.ios.scss index effa4969e0..38eae1ee58 100644 --- a/core/src/components/picker/picker.ios.scss +++ b/core/src/components/picker/picker.ios.scss @@ -39,7 +39,7 @@ } .picker-button, -.picker-button.activated { +.picker-button.ion-activated { @include margin(0); @include padding($picker-ios-button-padding-top, $picker-ios-button-padding-end, $picker-ios-button-padding-bottom, $picker-ios-button-padding-start); diff --git a/core/src/components/picker/picker.md.scss b/core/src/components/picker/picker.md.scss index 347d0b50d3..c656e0de7b 100644 --- a/core/src/components/picker/picker.md.scss +++ b/core/src/components/picker/picker.md.scss @@ -23,7 +23,7 @@ } .picker-button, -.picker-button.activated { +.picker-button.ion-activated { @include margin(0); @include padding(0, 1.1em); diff --git a/core/src/components/radio/radio.ios.scss b/core/src/components/radio/radio.ios.scss index 5086919c7b..331d8c184a 100644 --- a/core/src/components/radio/radio.ios.scss +++ b/core/src/components/radio/radio.ios.scss @@ -41,6 +41,7 @@ // iOS Radio: Disabled // ----------------------------------------- + :host(.radio-disabled) { opacity: $radio-ios-disabled-opacity; } diff --git a/core/src/components/searchbar/searchbar.md.scss b/core/src/components/searchbar/searchbar.md.scss index 7b77956dae..599c44c9d5 100644 --- a/core/src/components/searchbar/searchbar.md.scss +++ b/core/src/components/searchbar/searchbar.md.scss @@ -48,8 +48,8 @@ position: absolute; } -.searchbar-search-icon.activated, -.searchbar-cancel-button.activated { +.searchbar-search-icon.ion-activated, +.searchbar-cancel-button.ion-activated { background-color: transparent; } @@ -87,7 +87,7 @@ background-color: transparent; } -.searchbar-clear-button.activated { +.searchbar-clear-button.ion-activated { background-color: transparent; } diff --git a/core/src/components/segment-button/readme.md b/core/src/components/segment-button/readme.md index 615ef02f4c..fb1d9f6bc0 100644 --- a/core/src/components/segment-button/readme.md +++ b/core/src/components/segment-button/readme.md @@ -631,34 +631,36 @@ export const SegmentButtonExample: React.FC = () => ( ## CSS Custom Properties -| Name | Description | -| ------------------------ | ----------------------------------------------------------------------------------------------------------------- | -| `--background` | Background of the segment button | -| `--background-checked` | Background of the checked segment button | -| `--background-disabled` | Background of the disabled segment button | -| `--background-hover` | Background of the segment button on hover | -| `--border-color` | Color of the segment button border | -| `--border-radius` | Radius of the segment button border | -| `--border-style` | Style of the segment button border | -| `--border-width` | Width of the segment button border | -| `--color` | Color of the segment button | -| `--color-checked` | Color of the checked segment button | -| `--color-disabled` | Color of the disabled segment button | -| `--color-hover` | Color of the segment button on hover | -| `--indicator-box-shadow` | Box shadow on the indicator for the checked segment button | -| `--indicator-color` | Color of the indicator for the checked segment button | -| `--indicator-height` | Height of the indicator for the checked segment button | -| `--indicator-transform` | Transform of the indicator for the checked segment button | -| `--indicator-transition` | Transition of the indicator for the checked segment button | -| `--margin-bottom` | Bottom margin of the segment button | -| `--margin-end` | Right margin if direction is left-to-right, and left margin if direction is right-to-left of the segment button | -| `--margin-start` | Left margin if direction is left-to-right, and right margin if direction is right-to-left of the segment button | -| `--margin-top` | Top margin of the segment button | -| `--padding-bottom` | Bottom padding of the segment button | -| `--padding-end` | Right padding if direction is left-to-right, and left padding if direction is right-to-left of the segment button | -| `--padding-start` | Left padding if direction is left-to-right, and right padding if direction is right-to-left of the segment button | -| `--padding-top` | Top padding of the segment button | -| `--transition` | Transition of the segment button | +| Name | Description | +| ------------------------------ | ----------------------------------------------------------------------------------------------------------------- | +| `--background` | Background of the segment button | +| `--background-checked` | Background of the checked segment button | +| `--background-focused` | Background of the segment button when focused with the tab key | +| `--background-focused-opacity` | Opacity of the segment button background when focused with the tab key | +| `--background-hover` | Background of the segment button on hover | +| `--background-hover-opacity` | Opacity of the segment button background on hover | +| `--border-color` | Color of the segment button border | +| `--border-radius` | Radius of the segment button border | +| `--border-style` | Style of the segment button border | +| `--border-width` | Width of the segment button border | +| `--color` | Color of the segment button | +| `--color-checked` | Color of the checked segment button | +| `--color-focused` | Color of the segment button when focused with the tab key | +| `--color-hover` | Color of the segment button on hover | +| `--indicator-box-shadow` | Box shadow on the indicator for the checked segment button | +| `--indicator-color` | Color of the indicator for the checked segment button | +| `--indicator-height` | Height of the indicator for the checked segment button | +| `--indicator-transform` | Transform of the indicator for the checked segment button | +| `--indicator-transition` | Transition of the indicator for the checked segment button | +| `--margin-bottom` | Bottom margin of the segment button | +| `--margin-end` | Right margin if direction is left-to-right, and left margin if direction is right-to-left of the segment button | +| `--margin-start` | Left margin if direction is left-to-right, and right margin if direction is right-to-left of the segment button | +| `--margin-top` | Top margin of the segment button | +| `--padding-bottom` | Bottom padding of the segment button | +| `--padding-end` | Right padding if direction is left-to-right, and left padding if direction is right-to-left of the segment button | +| `--padding-start` | Left padding if direction is left-to-right, and right padding if direction is right-to-left of the segment button | +| `--padding-top` | Top padding of the segment button | +| `--transition` | Transition of the segment button | ## Dependencies diff --git a/core/src/components/segment-button/segment-button.ios.scss b/core/src/components/segment-button/segment-button.ios.scss index c04a9331d5..51d36e1dc2 100644 --- a/core/src/components/segment-button/segment-button.ios.scss +++ b/core/src/components/segment-button/segment-button.ios.scss @@ -5,9 +5,12 @@ // -------------------------------------------------- :host { - --background: #{$segment-button-ios-background-color}; - --background-checked: #{$segment-button-ios-background-color-checked}; - --background-hover: #{$segment-button-ios-background-color-hover}; + --background: #{$segment-button-ios-background}; + --background-checked: #{$segment-button-ios-background-checked}; + --background-hover: #{$segment-button-ios-background-hover}; + --background-hover-opacity: 0; + --background-focused: none; + --background-focused-opacity: 0; --border-radius: #{$segment-button-ios-border-radius}; --border-width: #{$segment-button-ios-border-width}; --border-color: #{$segment-button-ios-border-color}; @@ -134,16 +137,89 @@ } +// Segment: States +// -------------------------------------------------- + +:host(.ion-focused) .button-native { + opacity: $segment-button-ios-opacity-focused; +} + +@media (any-hover: hover) { + // Default Segment, Hover + :host(:hover) .button-native { + opacity: $segment-button-ios-opacity-hover; + } + + :host(.segment-button-checked:hover) .button-native { + opacity: 1; + } +} + + +// Segment Button: Segment w/ Color +// -------------------------------------------------- + +// Default +:host(.in-segment-color) { + background: none; + color: $segment-button-ios-color; +} + +// Indicator color on a Segment w/ color +// should not change if the variable is set +:host(.in-segment-color) .segment-button-indicator-background { + background: $segment-button-ios-indicator-color; +} + +@media (any-hover: hover) { + // Toolbar with Color, Default Segment, Hover + // Toolbar with Color, Default Segment, Checked, Hover + :host(.in-segment-color:hover) .button-native, + :host(.in-segment-color.segment-button-checked:hover) .button-native { + color: $segment-button-ios-color; + } +} + + + // Segment Button: Toolbar // -------------------------------------------------- -// Segment button indicator color should use the global variable with -// a fallback to the local variable -:host(.in-toolbar) .segment-button-indicator-background { - background: #{var(--ion-toolbar-segment-indicator-color, var(--indicator-color))}; +// Default Segment, In a Toolbar +:host(.in-toolbar:not(.in-segment-color)) { + --background-checked: #{var(--ion-toolbar-segment-background-checked, $segment-button-ios-background-checked)}; + --color: var(--ion-toolbar-segment-color, var(--ion-toolbar-color), initial); + --color-checked: var(--ion-toolbar-segment-color-checked, var(--ion-toolbar-color), initial); + --indicator-color: #{var(--ion-toolbar-segment-indicator-color, $segment-button-ios-indicator-color)}; } + +// Segment Button: Toolbar w/ Color +// -------------------------------------------------- + // Do not use the global or local CSS variable if the toolbar has a color :host(.in-toolbar-color) .segment-button-indicator-background { background: #fff; } + +// Toolbar with Color, Default Segment +:host(.in-toolbar-color:not(.in-segment-color)) .button-native { + color: #{current-color(contrast)}; +} + +// Toolbar with Color, Default Segment, Checked +:host(.in-toolbar-color.segment-button-checked:not(.in-segment-color)) .button-native { + color: #{current-color(base)}; +} + +@media (any-hover: hover) { + // Toolbar with Color, Default Segment, Hover + :host(.in-toolbar-color:not(.in-segment-color):hover) .button-native { + color: #{current-color(contrast)}; + } + + // Toolbar with Color, Default Segment, Checked / Hover + :host(.in-toolbar-color.segment-button-checked:not(.in-segment-color):hover) .button-native { + color: #{current-color(base)}; + } +} diff --git a/core/src/components/segment-button/segment-button.ios.vars.scss b/core/src/components/segment-button/segment-button.ios.vars.scss index 7d74903151..c02544fc34 100644 --- a/core/src/components/segment-button/segment-button.ios.vars.scss +++ b/core/src/components/segment-button/segment-button.ios.vars.scss @@ -4,10 +4,13 @@ // -------------------------------------------------- /// @prop - Background of the segment button -$segment-button-ios-background-color: transparent !default; +$segment-button-ios-background: none !default; /// @prop - Background of the checked segment button -$segment-button-ios-background-color-checked: transparent !default; +$segment-button-ios-background-checked: $segment-button-ios-background !default; + +/// @prop - Text color of the segment button +$segment-button-ios-color: $text-color !default; /// @prop - Background of the checked segment button indicator $segment-button-ios-indicator-color: var(--ion-color-step-350, $background-color) !default; @@ -18,11 +21,14 @@ $segment-button-ios-margin: 2px !default; /// @prop - Opacity of the segment button on hover $segment-button-ios-opacity-hover: .5 !default; +/// @prop - Opacity of the segment button when focused +$segment-button-ios-opacity-focused: .7 !default; + /// @prop - Opacity of the disabled segment button $segment-button-ios-opacity-disabled: .3 !default; /// @prop - Background of the segment button on hover -$segment-button-ios-background-color-hover: transparent !default; +$segment-button-ios-background-hover: none !default; /// @prop - Box shadow of the checked segment button $segment-button-ios-box-shadow-checked: 0 0 5px rgba(0, 0, 0, 0.16) !default; diff --git a/core/src/components/segment-button/segment-button.md.scss b/core/src/components/segment-button/segment-button.md.scss index 7d9c9b1be5..ce4088b023 100644 --- a/core/src/components/segment-button/segment-button.md.scss +++ b/core/src/components/segment-button/segment-button.md.scss @@ -7,7 +7,11 @@ :host { --background: #{$segment-button-md-background}; --background-checked: #{$segment-button-md-background-checked}; - --background-hover: #{$segment-button-md-background-hover}; + --background-hover: var(--color-checked); + --background-focused: var(--color-checked); + --background-activated-opacity: 0; + --background-focused-opacity: .12; + --background-hover-opacity: .04; --color: #{$segment-button-md-text-color}; --color-checked: #{$segment-button-md-text-color-checked}; --indicator-box-shadow: none; @@ -48,6 +52,84 @@ opacity: $segment-button-md-opacity-disabled; } + +// Segment Button: Segment w/ Color +// -------------------------------------------------- + +// Default +:host(.in-segment-color) { + background: none; + color: $segment-button-md-text-color; +} + +// Indicator color and ripple on a Segment w/ color +// should not change if the variables are set +:host(.in-segment-color) ion-ripple-effect { + color: #{current-color(base)}; +} + +:host(.in-segment-color) .segment-button-indicator-background { + background: #{current-color(base)}; +} + +// Checked +:host(.in-segment-color.segment-button-checked) .button-native { + color: #{current-color(base)}; +} + +// Focused +:host(.in-segment-color.ion-focused) .button-native::after { + background: #{current-color(base)}; +} + +@media (any-hover: hover) { + :host(.in-segment-color:hover) .button-native { + color: $segment-button-md-text-color; + + &::after { + background: #{current-color(base)}; + } + } + + :host(.in-segment-color.segment-button-checked:hover) .button-native { + color: #{current-color(base)}; + } +} + + +// Segment: Default Toolbar +// -------------------------------------------------- + +:host(.in-toolbar:not(.in-segment-color)) { + --background: #{var(--ion-toolbar-segment-background, $segment-button-md-background)}; + --background-checked: #{var(--ion-toolbar-segment-background-checked, $segment-button-md-background-checked)}; + --color: #{var(--ion-toolbar-segment-color, $segment-button-md-text-color)}; + --color-checked: #{var(--ion-toolbar-segment-color-checked, $segment-button-md-text-color-checked)}; + --indicator-color: #{var(--ion-toolbar-segment-color-checked, var(--color-checked))}; +} + + +// Segment Button: Toolbar w/ Color +// -------------------------------------------------- + +// Default Segment, In a Toolbar with Color +:host(.in-toolbar-color:not(.in-segment-color)) .button-native { + color: #{current-color(contrast, .6)}; +} + +// Default Segment, In a Toolbar with Color, Checked +:host(.in-toolbar-color.segment-button-checked:not(.in-segment-color)) .button-native { + color: #{current-color(contrast)}; +} + +// Default Segment, In a Toolbar with Color, Hover +@media (any-hover: hover) { + :host(.in-toolbar-color:not(.in-segment-color)) .button-native::after { + background: #{current-color(contrast)}; + } +} + + // Segment Button: Icon // -------------------------------------------------- diff --git a/core/src/components/segment-button/segment-button.md.vars.scss b/core/src/components/segment-button/segment-button.md.vars.scss index d01883ec2d..a4800a3716 100644 --- a/core/src/components/segment-button/segment-button.md.vars.scss +++ b/core/src/components/segment-button/segment-button.md.vars.scss @@ -9,24 +9,21 @@ $segment-button-md-opacity: .6 !default; /// @prop - Text color of the segment button $segment-button-md-text-color: rgba($text-color-rgb, $segment-button-md-opacity) !default; +/// @prop - Text color of the checked segment button +$segment-button-md-text-color-checked: ion-color(primary, base) !default; + /// @prop - Background of the segment button $segment-button-md-background: none !default; /// @prop - Background of the checked segment button $segment-button-md-background-checked: $segment-button-md-background !default; -/// @prop - Background of the hovered segment button -$segment-button-md-background-hover: ion-color(primary, base, .04) !default; - /// @prop - Width of the bottom border on the segment button $segment-button-md-border-bottom-width: 2px !default; /// @prop - Color of the bottom border on the segment button $segment-button-md-border-bottom-color: transparent !default; -/// @prop - Text color of the checked segment button -$segment-button-md-text-color-checked: ion-color(primary, base) !default; - /// @prop - Opacity of the disabled segment button $segment-button-md-opacity-disabled: .3 !default; diff --git a/core/src/components/segment-button/segment-button.scss b/core/src/components/segment-button/segment-button.scss index 28d8c0b725..1043095746 100644 --- a/core/src/components/segment-button/segment-button.scss +++ b/core/src/components/segment-button/segment-button.scss @@ -7,13 +7,17 @@ /** * @prop --background: Background of the segment button * @prop --background-checked: Background of the checked segment button - * @prop --background-disabled: Background of the disabled segment button + * * @prop --background-hover: Background of the segment button on hover + * @prop --background-focused: Background of the segment button when focused with the tab key + * + * @prop --background-hover-opacity: Opacity of the segment button background on hover + * @prop --background-focused-opacity: Opacity of the segment button background when focused with the tab key * * @prop --color: Color of the segment button * @prop --color-checked: Color of the checked segment button - * @prop --color-disabled: Color of the disabled segment button * @prop --color-hover: Color of the segment button on hover + * @prop --color-focused: Color of the segment button when focused with the tab key * * @prop --border-radius: Radius of the segment button border * @prop --border-color: Color of the segment button border @@ -39,7 +43,7 @@ * @prop --indicator-transform: Transform of the indicator for the checked segment button */ --color: initial; - --color-hover: initial; + --color-hover: var(--color); --color-checked: var(--color); --color-disabled: var(--color); --padding-start: 0; @@ -105,9 +109,29 @@ contain: content; cursor: pointer; + overflow: hidden; + z-index: 2; } +.button-native::after { + @include button-state(); +} + +.button-inner { + display: flex; + position: relative; + + flex-flow: inherit; + align-items: center; + justify-content: center; + + width: 100%; + height: 100%; + + z-index: 1; +} + // Segment Button: Checked // -------------------------------------------------- @@ -122,22 +146,40 @@ // -------------------------------------------------- :host(.segment-button-disabled) { - background: var(--background-disabled); - color: var(--color-disabled); + cursor: default; + pointer-events: none; } +// Segment Button: Focused +// -------------------------------------------------- + +:host(.ion-focused) .button-native { + color: var(--color-focused); + + &::after { + background: var(--background-focused); + + opacity: var(--background-focused-opacity); + } +} + // Segment Button: Hover // -------------------------------------------------- @media (any-hover: hover) { - :host(:hover) { - background: var(--background-hover); - color: var(--color-hover, var(--color)); + :host(:hover) .button-native { + color: var(--color-hover); + + &::after { + background: var(--background-hover); + + opacity: var(--background-hover-opacity); + } } - :host(.segment-button-checked:hover) { - color: var(--color-hover, var(--color-checked)); + :host(.segment-button-checked:hover) .button-native { + color: var(--color-checked); } } diff --git a/core/src/components/segment-button/segment-button.tsx b/core/src/components/segment-button/segment-button.tsx index 1cdfcc3c37..1bacfe1407 100644 --- a/core/src/components/segment-button/segment-button.tsx +++ b/core/src/components/segment-button/segment-button.tsx @@ -88,6 +88,8 @@ export class SegmentButton implements ComponentInterface, ButtonInterface { [mode]: true, 'in-toolbar': hostContext('ion-toolbar', this.el), 'in-toolbar-color': hostContext('ion-toolbar[color]', this.el), + 'in-segment': hostContext('ion-segment', this.el), + 'in-segment-color': hostContext('ion-segment[color]', this.el), 'segment-button-has-label': hasLabel, 'segment-button-has-icon': hasIcon, 'segment-button-has-label-only': hasLabel && !hasIcon, @@ -97,6 +99,7 @@ export class SegmentButton implements ComponentInterface, ButtonInterface { [`segment-button-layout-${layout}`]: true, 'ion-activatable': true, 'ion-activatable-instant': true, + 'ion-focusable': true, }} >
this.onEnd(ev), }); this.gesture.enable(!this.scrollable); - this.disabledChanged(); + this.gestureChanged(); + + if (this.disabled) { + this.disabledChanged(); + } this.didInit = true; } diff --git a/core/src/components/segment/test/basic/index.html b/core/src/components/segment/test/basic/index.html index cad6fb37de..f678bc896e 100644 --- a/core/src/components/segment/test/basic/index.html +++ b/core/src/components/segment/test/basic/index.html @@ -103,13 +103,13 @@ - + - + diff --git a/core/src/components/segment/test/colors/e2e.ts b/core/src/components/segment/test/colors/e2e.ts index c026c7afb6..f026f7d26f 100644 --- a/core/src/components/segment/test/colors/e2e.ts +++ b/core/src/components/segment/test/colors/e2e.ts @@ -1,8 +1,8 @@ import { newE2EPage } from '@stencil/core/testing'; -test('segment: basic', async () => { +test('segment: colors', async () => { const page = await newE2EPage({ - url: '/src/components/segment/test/basic?ionic:_testing=true' + url: '/src/components/segment/test/colors?ionic:_testing=true' }); await page.waitFor(250); @@ -11,9 +11,9 @@ test('segment: basic', async () => { expect(compare).toMatchScreenshot(); }); -test('segment:rtl: basic', async () => { +test('segment:rtl: colors', async () => { const page = await newE2EPage({ - url: '/src/components/segment/test/basic?ionic:_testing=true&rtl=true' + url: '/src/components/segment/test/colors?ionic:_testing=true&rtl=true' }); await page.waitFor(250); diff --git a/core/src/components/segment/test/colors/index.html b/core/src/components/segment/test/colors/index.html index 008a9d955a..0d77fc70de 100644 --- a/core/src/components/segment/test/colors/index.html +++ b/core/src/components/segment/test/colors/index.html @@ -23,6 +23,7 @@ + Paid @@ -35,135 +36,149 @@ - - - Bookmarks - - - Reading List - - - Shared Links - - +
+ + + Custom + + + Colors + + + All + + - - - Active - - - Disabled - - - Inactive - - + + + Bookmarks + + + Reading List + + + Shared Links + + - - - All - - - Missed - - + + + Active + + + Disabled + + + Inactive + + - - - 330ml - - - 440ml - - - 500ml - - - - - + + + All + + + Missed + + - - - - - - - - - - - + + + 330ml + + + 440ml + + + 500ml + + + + + - - - Bookmarks - - - Reading List - - - Shared Links - - + + + + + + + + + + + + + + + Bookmarks + + + Reading List + + + Shared Links + + - - - Sunny - - - Rainy - - + + + Sunny + + + Rainy + + - - - Seg 1 - - - Seg 2 - - - Seg 3 - - + + + Seg 1 + + + Seg 2 + + + Seg 3 + + - - - Seg 2 1 - - - Seg 2 2 - - - Seg 2 3 - - + + + Seg 2 1 + + + Seg 2 2 + + + Seg 2 3 + + - - - Seg 2 1 - - - Seg 2 2 - - - Seg 2 3 - - + + + Seg 2 1 + + + Seg 2 2 + + + Seg 2 3 + + - - - Seg 2 1 - - - Seg 2 2 - - - Seg 2 3 - - + + + Seg 2 1 + + + Seg 2 2 + + + Seg 2 3 + + +
diff --git a/core/src/components/segment/test/toolbar/index.html b/core/src/components/segment/test/toolbar/index.html index ddb44c3302..b9e991ea48 100644 --- a/core/src/components/segment/test/toolbar/index.html +++ b/core/src/components/segment/test/toolbar/index.html @@ -126,7 +126,7 @@ - + Item One diff --git a/core/src/components/tab-bar/tab-bar.ios.scss b/core/src/components/tab-bar/tab-bar.ios.scss index f035bf2bb4..1993928ec3 100644 --- a/core/src/components/tab-bar/tab-bar.ios.scss +++ b/core/src/components/tab-bar/tab-bar.ios.scss @@ -10,7 +10,7 @@ --background-focused: #{$tabbar-ios-background-focused}; --border: #{$hairlines-width solid $tabbar-ios-border-color}; --color: #{$tab-button-ios-text-color}; - --color-selected: #{$tabbar-ios-color-activated}; + --color-selected: #{$tabbar-ios-color-selected}; height: 50px; } diff --git a/core/src/components/tab-bar/tab-bar.md.scss b/core/src/components/tab-bar/tab-bar.md.scss index 4363520fad..5b2346936a 100644 --- a/core/src/components/tab-bar/tab-bar.md.scss +++ b/core/src/components/tab-bar/tab-bar.md.scss @@ -8,7 +8,7 @@ --background-focused: #{$tabbar-md-background-focused}; --border: #{1px solid $tabbar-md-border-color}; --color: #{$tab-button-md-text-color}; - --color-selected: #{$tabbar-md-color-activated}; + --color-selected: #{$tabbar-md-color-selected}; height: 56px; } \ No newline at end of file diff --git a/core/src/components/tab-bar/test/basic/index.html b/core/src/components/tab-bar/test/basic/index.html index 07febe05c9..17c908274b 100644 --- a/core/src/components/tab-bar/test/basic/index.html +++ b/core/src/components/tab-bar/test/basic/index.html @@ -4,193 +4,199 @@ Tab Bar - Preview - + - + + - - + + + + - - Recents - + + Recents + - - Favorites - 23 - + + Favorites + 23 + - - Settings - + + Settings + - + - - - - - Favorites - - + + + + + Favorites + + - - - + + + - - - + + + - - - 47 - - + + + 47 + + - - - - + + + + - - - Favorites - + + + Favorites + - - - 88 - + + + 88 + - - - - + + + + - - - - + + + + - - - + + + - - - - + + + + - - - - Location - - + + + + Location + + - - 44 - - + + 44 + + - - Radio - - + + Radio + + - + - - - - Recents - - + + + + Recents + + - - 16 - Favorites - - + + 16 + Favorites + + - - Settings - - - + + Settings + + + - - - - Recents - - + + + + Recents + + - - Favorites - - 33 - + + Favorites + + 33 + - - Settings - - + + Settings + + - + - - - - Recents - - 12 - + + + + Recents + + 12 + - - Favorites - - + + Favorites + + - - Settings - - + + Settings + + - + - - - - Recents - - + + + + Recents + + - - Favorites - - + + Favorites + + - - Settings - - 2 - - + + Settings + + 2 + + + + diff --git a/core/src/components/tab-button/readme.md b/core/src/components/tab-button/readme.md index 13bba94407..3ab5fafc06 100644 --- a/core/src/components/tab-button/readme.md +++ b/core/src/components/tab-button/readme.md @@ -175,17 +175,19 @@ export const TabButtonExample: React.FC = () => ( ## CSS Custom Properties -| Name | Description | -| ---------------------- | ------------------------------------------------------------------------------------------------------------- | -| `--background` | Background of the tab button | -| `--background-focused` | Background of the tab button when focused with the tab key | -| `--color` | Color of the tab button | -| `--color-selected` | Color of the selected tab button | -| `--padding-bottom` | Bottom padding of the tab button | -| `--padding-end` | Right padding if direction is left-to-right, and left padding if direction is right-to-left of the tab button | -| `--padding-start` | Left padding if direction is left-to-right, and right padding if direction is right-to-left of the tab button | -| `--padding-top` | Top padding of the tab button | -| `--ripple-color` | Color of the button ripple effect | +| Name | Description | +| ------------------------------ | ------------------------------------------------------------------------------------------------------------- | +| `--background` | Background of the tab button | +| `--background-focused` | Background of the tab button when focused with the tab key | +| `--background-focused-opacity` | Opacity of the tab button background when focused with the tab key | +| `--color` | Color of the tab button | +| `--color-focused` | Color of the tab button when focused with the tab key | +| `--color-selected` | Color of the selected tab button | +| `--padding-bottom` | Bottom padding of the tab button | +| `--padding-end` | Right padding if direction is left-to-right, and left padding if direction is right-to-left of the tab button | +| `--padding-start` | Left padding if direction is left-to-right, and right padding if direction is right-to-left of the tab button | +| `--padding-top` | Top padding of the tab button | +| `--ripple-color` | Color of the button ripple effect | ## Dependencies diff --git a/core/src/components/tab-button/tab-button.ios.vars.scss b/core/src/components/tab-button/tab-button.ios.vars.scss index 1e1df6d540..38b2e212ab 100644 --- a/core/src/components/tab-button/tab-button.ios.vars.scss +++ b/core/src/components/tab-button/tab-button.ios.vars.scss @@ -22,13 +22,13 @@ $tab-button-ios-max-width: 240px !default; $tab-button-ios-text-color: $tabbar-ios-color !default; /// @prop - Text color of the active tab button -$tab-button-ios-text-color-active: $tabbar-ios-color-activated !default; +$tab-button-ios-text-color-active: $tabbar-ios-color-selected !default; /// @prop - Icon color of the inactive tab button $tab-button-ios-icon-color: $tabbar-ios-color !default; /// @prop - Icon color of the active tab button -$tab-button-ios-icon-color-active: $tabbar-ios-color-activated !default; +$tab-button-ios-icon-color-active: $tabbar-ios-color-selected !default; /// @prop - Font size of the tab button text $tab-button-ios-font-size: 10px !default; diff --git a/core/src/components/tab-button/tab-button.md.vars.scss b/core/src/components/tab-button/tab-button.md.vars.scss index 32d2db7968..4007dc94eb 100644 --- a/core/src/components/tab-button/tab-button.md.vars.scss +++ b/core/src/components/tab-button/tab-button.md.vars.scss @@ -28,13 +28,13 @@ $tab-button-md-font-weight: normal !default; $tab-button-md-text-color: $tabbar-md-color !default; /// @prop - Text color of the active tab button -$tab-button-md-text-color-active: $tabbar-md-color-activated !default; +$tab-button-md-text-color-active: $tabbar-md-color-selected !default; /// @prop - Icon color of the inactive tab button $tab-button-md-icon-color: $tabbar-md-color !default; /// @prop - Icon color of the active tab button -$tab-button-md-icon-color-active: $tabbar-md-color-activated !default; +$tab-button-md-icon-color-active: $tabbar-md-color-selected !default; /// @prop - Margin top on the tab button icon $tab-button-md-icon-margin-top: 16px !default; diff --git a/core/src/components/tab-button/tab-button.scss b/core/src/components/tab-button/tab-button.scss index 7e81262993..7bfd405dd3 100644 --- a/core/src/components/tab-button/tab-button.scss +++ b/core/src/components/tab-button/tab-button.scss @@ -4,8 +4,10 @@ /** * @prop --background: Background of the tab button * @prop --background-focused: Background of the tab button when focused with the tab key + * @prop --background-focused-opacity: Opacity of the tab button background when focused with the tab key * * @prop --color: Color of the tab button + * @prop --color-focused: Color of the tab button when focused with the tab key * @prop --color-selected: Color of the selected tab button * * @prop --padding-top: Top padding of the tab button @@ -16,6 +18,7 @@ * @prop --ripple-color: Color of the button ripple effect */ --ripple-color: var(--color-selected); + --background-focused-opacity: 1; flex: 1; @@ -34,7 +37,8 @@ // Tab Button: Native // -------------------------------------------------- -a { +.button-native { + @include border-radius(inherit); @include margin(0); @include padding(var(--padding-top), var(--padding-end), var(--padding-bottom), var(--padding-start)); @include text-inherit(); @@ -63,8 +67,35 @@ a { -webkit-user-drag: none; } -:host(.ion-focused) { - background: var(--background-focused); +.button-native::after { + @include button-state(); +} + +.button-inner { + display: flex; + position: relative; + + flex-flow: inherit; + align-items: inherit; + justify-content: inherit; + + width: 100%; + height: 100%; + + z-index: 1; +} + +// Tab Button: States +// -------------------------------------------------- + +:host(.ion-focused) .button-native { + color: var(--color-focused); + + &::after { + background: var(--background-focused); + + opacity: var(--background-focused-opacity); + } } @media (any-hover: hover) { @@ -73,10 +104,6 @@ a { } } - -// Tab Button: States -// -------------------------------------------------- - :host(.tab-selected) { color: var(--color-selected); } diff --git a/core/src/components/tab-button/tab-button.tsx b/core/src/components/tab-button/tab-button.tsx index 0dd379bac7..88aef7b28a 100644 --- a/core/src/components/tab-button/tab-button.tsx +++ b/core/src/components/tab-button/tab-button.tsx @@ -161,8 +161,10 @@ export class TabButton implements ComponentInterface, AnchorInterface { 'ion-focusable': true }} > -
- + + + + {mode === 'md' && } diff --git a/core/src/components/toast/toast.ios.scss b/core/src/components/toast/toast.ios.scss index a44d8132d9..6aaf99db92 100644 --- a/core/src/components/toast/toast.ios.scss +++ b/core/src/components/toast/toast.ios.scss @@ -79,7 +79,7 @@ overflow: hidden; } -.toast-button.activated { +.toast-button.ion-activated { opacity: $toast-ios-button-opacity-activated; } diff --git a/core/src/components/toolbar/test/colors/index.html b/core/src/components/toolbar/test/colors/index.html index b2332f6f99..48ec1d8900 100644 --- a/core/src/components/toolbar/test/colors/index.html +++ b/core/src/components/toolbar/test/colors/index.html @@ -48,6 +48,22 @@ Primary + + + + + + Outline + + + Clear + + + + + Primary + + @@ -64,6 +80,22 @@ Secondary + + + + + + Solid + + + Clear + + + + + Secondary + + @@ -80,6 +112,22 @@ Tertiary + + + + + + Outline + + + Clear + + + + + Tertiary + + @@ -112,6 +160,22 @@ Warning + + + + + + Outline + + + Clear + + + + + Warning + + diff --git a/core/src/components/toolbar/test/scenarios/index.html b/core/src/components/toolbar/test/scenarios/index.html index fe5ba50223..b80679f5aa 100644 --- a/core/src/components/toolbar/test/scenarios/index.html +++ b/core/src/components/toolbar/test/scenarios/index.html @@ -58,15 +58,15 @@ - + - + - + @@ -94,17 +94,17 @@ - + - + Solid Solid Activated - + Help @@ -131,16 +131,16 @@ - + - + Star - + diff --git a/core/src/components/toolbar/toolbar.md.vars.scss b/core/src/components/toolbar/toolbar.md.vars.scss index 5e8ce94ddf..57b423a85d 100644 --- a/core/src/components/toolbar/toolbar.md.vars.scss +++ b/core/src/components/toolbar/toolbar.md.vars.scss @@ -24,9 +24,6 @@ $toolbar-md-button-color: $toolbar-md-color !default; /// @prop - Background color of the toolbar button $toolbar-md-button-background-color: $toolbar-md-background !default; -/// @prop - Background color of the toolbar button when activated -$toolbar-md-button-background-color-activated: $toolbar-md-color-activated !default; - /// @prop - Border radius of the toolbar button $toolbar-md-button-border-radius: 2px !default; diff --git a/core/src/themes/ionic.mixins.scss b/core/src/themes/ionic.mixins.scss index 31410387e8..3eaa4a6e2d 100644 --- a/core/src/themes/ionic.mixins.scss +++ b/core/src/themes/ionic.mixins.scss @@ -35,6 +35,16 @@ color: inherit; } +@mixin button-state() { + @include position(0, 0, 0, 0); + + position: absolute; + + content: ""; + + opacity: 0; +} + // Font smoothing // -------------------------------------------------- diff --git a/core/src/themes/ionic.theme.default.ios.scss b/core/src/themes/ionic.theme.default.ios.scss index 1b5912cf76..fa5b3f701b 100644 --- a/core/src/themes/ionic.theme.default.ios.scss +++ b/core/src/themes/ionic.theme.default.ios.scss @@ -17,20 +17,16 @@ $tabbar-ios-background: var(--ion-tab-bar-background, $backg $tabbar-ios-background-focused: var(--ion-tab-bar-background-focused, get-color-shade(#fff)) !default; $tabbar-ios-border-color: var(--ion-tab-bar-border-color, var(--ion-border-color, var(--ion-color-step-150, rgba(0, 0, 0, .2)))) !default; $tabbar-ios-color: var(--ion-tab-bar-color, $text-color-step-550) !default; -$tabbar-ios-color-activated: var(--ion-tab-bar-color-activated, ion-color(primary, base)) !default; +$tabbar-ios-color-selected: var(--ion-tab-bar-color-selected, ion-color(primary, base)) !default; // iOS Toolbar // -------------------------------------------------- $toolbar-ios-background: var(--ion-toolbar-background, var(--ion-color-step-50, #fff)) !default; $toolbar-ios-border-color: var(--ion-toolbar-border-color, var(--ion-border-color, var(--ion-color-step-150, rgba(0, 0, 0, .2)))) !default; $toolbar-ios-color: var(--ion-toolbar-color, $text-color) !default; -$toolbar-ios-color-activated: var(--ion-toolbar-color-activated, ion-color(primary, base)) !default; // iOS List & List Items // -------------------------------------------------- $item-ios-background: var(--ion-item-background, $background-color) !default; -$item-ios-background-activated: var(--ion-item-background-activated, var(--ion-color-step-150, #d9d9d9)) !default; -$item-ios-background-focused: var(--ion-item-background-focused, var(--ion-color-step-100, #e1e1e1)) !default; -$item-ios-background-hover: var(--ion-item-background-hover, rgba($text-color-rgb, 0.04)) !default; $item-ios-border-color: var(--ion-item-border-color, var(--ion-border-color, var(--ion-color-step-250, #c8c7cc))) !default; $item-ios-color: var(--ion-item-color, $text-color) !default; \ No newline at end of file diff --git a/core/src/themes/ionic.theme.default.md.scss b/core/src/themes/ionic.theme.default.md.scss index cb829216f9..e708be279f 100644 --- a/core/src/themes/ionic.theme.default.md.scss +++ b/core/src/themes/ionic.theme.default.md.scss @@ -18,20 +18,16 @@ $tabbar-md-background: var(--ion-tab-bar-background, $backg $tabbar-md-background-focused: var(--ion-tab-bar-background-focused, get-color-shade(#fff)) !default; $tabbar-md-border-color: var(--ion-tab-bar-border-color, var(--ion-border-color, var(--ion-color-step-150, rgba(0, 0, 0, .07)))) !default; $tabbar-md-color: var(--ion-tab-bar-color, $text-color-step-400) !default; -$tabbar-md-color-activated: var(--ion-tab-bar-color-activated, ion-color(primary, base)) !default; +$tabbar-md-color-selected: var(--ion-tab-bar-color-selected, ion-color(primary, base)) !default; // Material Design Toolbar // -------------------------------------------------- $toolbar-md-background: var(--ion-toolbar-background, $background-color) !default; $toolbar-md-border-color: var(--ion-toolbar-border-color, $border-md-color) !default; $toolbar-md-color: var(--ion-toolbar-color, var(--ion-text-color, #424242)) !default; -$toolbar-md-color-activated: var(--ion-toolbar-color-activated, #4a4a4a) !default; // Material Design List & List Items // -------------------------------------------------- $item-md-background: var(--ion-item-background, $background-color) !default; -// activated item background does not exist in MD as it uses the ripple color -$item-md-background-focused: var(--ion-item-background-focused, var(--ion-color-step-100, #e1e1e1)) !default; -$item-md-background-hover: var(--ion-item-background-hover, rgba($text-color-rgb, 0.04)) !default; $item-md-border-color: var(--ion-item-border-color, var(--ion-border-color, var(--ion-color-step-150, rgba(0, 0, 0, .13)))) !default; $item-md-color: var(--ion-item-color, $text-color) !default; diff --git a/core/src/themes/test/css-variables/css/dark.css b/core/src/themes/test/css-variables/css/dark.css index 1e09d57c39..80a86af92c 100644 --- a/core/src/themes/test/css-variables/css/dark.css +++ b/core/src/themes/test/css-variables/css/dark.css @@ -94,6 +94,7 @@ --ion-item-background-activated: #313131; --ion-toolbar-background: #000; + --ion-toolbar-color: #fff; } .md { diff --git a/core/src/themes/test/css-variables/css/oceanic.css b/core/src/themes/test/css-variables/css/oceanic.css index 1eb325a1ab..81e6ca5172 100644 --- a/core/src/themes/test/css-variables/css/oceanic.css +++ b/core/src/themes/test/css-variables/css/oceanic.css @@ -84,11 +84,10 @@ --ion-tab-bar-background: #343d46; --ion-tab-bar-background-focused: #293039; --ion-tab-bar-color: #a7adba; - --ion-tab-bar-color-activated: #549ee7; + --ion-tab-bar-color-selected: #549ee7; --ion-toolbar-background: #343d46; --ion-toolbar-color: #a7adba; - --ion-toolbar-color-activated: var(--ion-color-primary); /* Background, Text, Step Colors */ --ion-background-color: #1b2b34; diff --git a/core/src/themes/test/css-variables/css/toolbar.css b/core/src/themes/test/css-variables/css/toolbar.css new file mode 100644 index 0000000000..693e988e70 --- /dev/null +++ b/core/src/themes/test/css-variables/css/toolbar.css @@ -0,0 +1,26 @@ +/** + * Toolbar + * ----------------------------------------------------- + * The toolbar theme customizes the toolbar only + * + * Looking to create a custom theme? Check out the generator! + * https://ionicframework.com/docs/theming/color-generator +**/ + +:root { + --ion-color-primary: #3880ff; + --ion-color-light: #f4f5f8; + --ion-color-light-rgb: 244, 245, 248; + + --ion-toolbar-background: var(--ion-color-primary); + --ion-toolbar-color: var(--ion-color-light); +} + +.md { + --ion-toolbar-segment-color: rgba(var(--ion-color-light-rgb), .7); + --ion-toolbar-segment-color-checked: var(--ion-color-light); +} + +.ios { + --ion-toolbar-segment-color-checked: var(--ion-color-primary); +} \ No newline at end of file diff --git a/core/src/themes/test/css-variables/css/vibrant.css b/core/src/themes/test/css-variables/css/vibrant.css index 21a4e19255..f6cad7ab53 100644 --- a/core/src/themes/test/css-variables/css/vibrant.css +++ b/core/src/themes/test/css-variables/css/vibrant.css @@ -78,20 +78,4 @@ --ion-item-background: #fff; --ion-item-border-color: #5bff76; --ion-item-background-activated: #5bff76; - - --ion-toolbar-color: #fff; } - -.ios { - --ion-toolbar-segment-background: var(--ion-color-danger); - --ion-toolbar-segment-color: var(--ion-color-danger-contrast); - - --ion-toolbar-segment-indicator-color: var(--ion-color-danger-contrast); - --ion-toolbar-segment-color-checked: var(--ion-color-danger); -} - -.md { - --ion-toolbar-segment-color: #fff; - --ion-toolbar-segment-color-checked: var(--ion-color-danger); - --ion-toolbar-segment-background-hover: rgba(var(--ion-color-danger-contrast-rgb), .04); -} \ No newline at end of file diff --git a/core/src/themes/test/css-variables/index.html b/core/src/themes/test/css-variables/index.html index 9b16280c2a..fc9074e4b0 100644 --- a/core/src/themes/test/css-variables/index.html +++ b/core/src/themes/test/css-variables/index.html @@ -88,32 +88,54 @@ Lists - Secondary Outline + + + Default + Solid + Clear + Outline - -
- Select a Theme: - - Default - Oceanic - Vibrant - Dark - -
- - - Favorites + + + + Default + Solid + Clear + Outline + + + Lists + + + + + Default + Solid + Clear + Outline + + + + + + Default - - All + + Oceanic - - Disabled + + Vibrant - - Active + + Dark + + + Toolbar + + + Disabled @@ -146,9 +168,9 @@ - + - Card Link Item 1 .activated + Card Link Item 1 activated @@ -156,14 +178,14 @@ Card Link Item 2 - + - Card Button Item 1 .activated + Card Button Item 1 activated - + - Card Button Item 2 + Card Button Item 2 focused @@ -182,7 +204,7 @@ Mega Man X Note - + The Legend of Zelda Note @@ -428,15 +450,15 @@

- Primary - Secondary - Tertiary - Success Outline - Warning Clear - Danger - Light - Medium Outline - Dark Clear + Primary + Secondary + Tertiary + Success Outline + Warning Clear + Danger + Light + Medium Outline + Dark Clear

@@ -562,34 +584,34 @@

- - All - Favorites + + All + Favorites - - All - Favorites + + All + Favorites - - All - Favorites + + All + Favorites - - All - Favorites + + All + Favorites - - All - Favorites + + All + Favorites - - All - Favorites + + All + Favorites

@@ -626,9 +648,9 @@
- - All - Favorites + + All + Favorites
@@ -703,9 +725,9 @@
- - All - Favorites + + All + Favorites
@@ -857,7 +879,7 @@ } }, { text: 'Play (open modal)', - icon: 'arrow-dropright-circle', + icon: 'chevron-forward-circle', handler: () => { console.log('Play clicked'); } @@ -968,11 +990,13 @@ async function presentToast() { const toast = Object.assign(document.createElement('ion-toast'), { - message: 'Your settings have been saved.', - duration: 2000 + message: 'Hello world!', + buttons: [ + { text: 'Close', role: 'close' } + ] }); document.body.appendChild(toast); - return await toast.present(); + await toast.present(); } diff --git a/core/src/utils/tap-click.ts b/core/src/utils/tap-click.ts index fd4e27105b..02cd574b49 100644 --- a/core/src/utils/tap-click.ts +++ b/core/src/utils/tap-click.ts @@ -185,7 +185,7 @@ const getRippleEffect = (el: HTMLElement) => { return el.querySelector('ion-ripple-effect'); }; -const ACTIVATED = 'activated'; +const ACTIVATED = 'ion-activated'; const ADD_ACTIVATED_DEFERS = 200; const CLEAR_STATE_DEFERS = 200; const MOUSE_WAIT = 2500;