Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(toggle): on/off icons for toggle #25459

Merged
merged 50 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d5c3527
feat(toggle): on/off icons for toggle
sean-perkins Jun 9, 2022
ef86503
fix(): iOS right-to-left styles
sean-perkins Jun 13, 2022
e1d9b32
test(toggle): visual regression test switch labels
sean-perkins Jun 13, 2022
bc1b7c2
refactor(): rename to switchLabelsEnabled
sean-perkins Jun 13, 2022
8050af1
chore(): stylint & prettier
sean-perkins Jun 13, 2022
f914a31
fix(): e2e test path
sean-perkins Jun 13, 2022
a5ec2d4
chore(): add updated snapshots
Ionitron Jun 13, 2022
10547e2
refactor(): pass in mode to render functions
sean-perkins Jun 13, 2022
a26cbef
refactor(): default value to undefined
sean-perkins Jun 13, 2022
39b5c57
refactor(): rename prop to enableOnOffLabels
sean-perkins Jun 13, 2022
54b7e35
fix(): dark mode iOS
sean-perkins Jun 13, 2022
a349c9b
fix(): material dark mode
sean-perkins Jun 14, 2022
7904464
fix(): hide on/off label when activated on iOS
sean-perkins Jun 14, 2022
4308233
fix(): iOS design
sean-perkins Jun 14, 2022
5ec1735
test(): dark mode visual regression tests
sean-perkins Jun 14, 2022
2397c5f
chore(): add updated snapshots
Ionitron Jun 14, 2022
e7989ba
test(): dismiss popover before dark mode screenshots
sean-perkins Jun 14, 2022
2fb5762
fix(): dark mode design
sean-perkins Jun 14, 2022
e7285a7
chore(): remove screenshots
sean-perkins Jun 14, 2022
793d777
chore(): add updated snapshots
Ionitron Jun 14, 2022
6723048
fix(): material dark mode
sean-perkins Jun 14, 2022
3793f2d
Merge remote-tracking branch 'origin/FW-884' into FW-884
sean-perkins Jun 14, 2022
433d2ac
chore(): prettier
sean-perkins Jun 14, 2022
78a79f9
chore(): remove reference screenshots
sean-perkins Jun 14, 2022
3131eea
chore(): add updated snapshots
Ionitron Jun 14, 2022
3b64cba
chore(): format comments in style block
sean-perkins Jun 14, 2022
22b0428
Merge remote-tracking branch 'origin/feature-6.2' into FW-884
sean-perkins Jun 15, 2022
6a27740
refactor(): use array to render both labels
sean-perkins Jun 15, 2022
55002dd
fix(): align on/off labels without flexbox
sean-perkins Jun 15, 2022
09ecc0d
fix(): icon sizes and color contrast
sean-perkins Jun 15, 2022
05d940e
chore(): remove screenshots
sean-perkins Jun 15, 2022
5b2730b
chore(): add updated snapshots
Ionitron Jun 15, 2022
fb99bf0
chore(): use ion-color-dark for unchecked ios label
sean-perkins Jun 15, 2022
dfe5265
Merge remote-tracking branch 'origin/FW-884' into FW-884
sean-perkins Jun 15, 2022
7b42989
chore(): remove reference screenshots
sean-perkins Jun 21, 2022
0bd0b31
chore(): add updated snapshots
Ionitron Jun 21, 2022
f52437a
chore(): remove bad screenshots
sean-perkins Jun 23, 2022
84fd8f0
chore(): add updated snapshots
Ionitron Jun 23, 2022
eab55d6
fix(sass): generated selector for rtl functions
sean-perkins Jun 24, 2022
fa82e3d
refactor(): adjust implementation to avoid changing sass functions
sean-perkins Jun 24, 2022
a2c6d97
chore(): remove bad screenshots
sean-perkins Jun 24, 2022
6184adb
chore(): add updated snapshots
Ionitron Jun 24, 2022
6724f69
refactor(): swap css class name away from BEM
sean-perkins Jul 5, 2022
5c24018
refactor(): css variables for label color and checked label color
sean-perkins Jul 5, 2022
ba8728a
Merge remote-tracking branch 'origin/feature-6.2' into FW-884
sean-perkins Jul 5, 2022
cc22dd4
Revert "refactor(): css variables for label color and checked label c…
sean-perkins Jul 5, 2022
f885bef
fix(): adjust label alignment on iOS
sean-perkins Jul 6, 2022
22fdede
chore(): clear reference screenshots
sean-perkins Jul 6, 2022
d32004d
chore(): add updated snapshots
Ionitron Jul 6, 2022
4515f87
Merge remote-tracking branch 'origin/feature-6.2' into FW-884
sean-perkins Jul 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2962,6 +2962,10 @@ export namespace Components {
* If `true`, the user cannot interact with the toggle.
*/
"disabled": boolean;
/**
* Enables the on/off accessibility switch labels within the toggle.
*/
"enableOnOffLabels": boolean | undefined;
/**
* The mode determines which platform styles to use.
*/
Expand Down Expand Up @@ -6897,6 +6901,10 @@ declare namespace LocalJSX {
* If `true`, the user cannot interact with the toggle.
*/
"disabled"?: boolean;
/**
* Enables the on/off accessibility switch labels within the toggle.
*/
"enableOnOffLabels"?: boolean | undefined;
/**
* The mode determines which platform styles to use.
*/
Expand Down
286 changes: 286 additions & 0 deletions core/src/components/toggle/test/enable-on-off-labels/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>Toggle - enableOnOffLabels</title>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet" />
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet" />
<script src="../../../../../scripts/testing/scripts.js"></script>
<script nomodule src="../../../../../dist/ionic/ionic.js"></script>
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>

<style>
body.dark {
--ion-color-primary: #428cff;
--ion-color-primary-rgb: 66, 140, 255;
--ion-color-primary-contrast: #ffffff;
--ion-color-primary-contrast-rgb: 255, 255, 255;
--ion-color-primary-shade: #3a7be0;
--ion-color-primary-tint: #5598ff;

--ion-color-secondary: #50c8ff;
--ion-color-secondary-rgb: 80, 200, 255;
--ion-color-secondary-contrast: #ffffff;
--ion-color-secondary-contrast-rgb: 255, 255, 255;
--ion-color-secondary-shade: #46b0e0;
--ion-color-secondary-tint: #62ceff;

--ion-color-tertiary: #6a64ff;
--ion-color-tertiary-rgb: 106, 100, 255;
--ion-color-tertiary-contrast: #ffffff;
--ion-color-tertiary-contrast-rgb: 255, 255, 255;
--ion-color-tertiary-shade: #5d58e0;
--ion-color-tertiary-tint: #7974ff;

--ion-color-success: #2fdf75;
--ion-color-success-rgb: 47, 223, 117;
--ion-color-success-contrast: #000000;
--ion-color-success-contrast-rgb: 0, 0, 0;
--ion-color-success-shade: #29c467;
--ion-color-success-tint: #44e283;

--ion-color-warning: #ffd534;
--ion-color-warning-rgb: 255, 213, 52;
--ion-color-warning-contrast: #000000;
--ion-color-warning-contrast-rgb: 0, 0, 0;
--ion-color-warning-shade: #e0bb2e;
--ion-color-warning-tint: #ffd948;

--ion-color-danger: #ff4961;
--ion-color-danger-rgb: 255, 73, 97;
--ion-color-danger-contrast: #ffffff;
--ion-color-danger-contrast-rgb: 255, 255, 255;
--ion-color-danger-shade: #e04055;
--ion-color-danger-tint: #ff5b71;

--ion-color-dark: #f4f5f8;
--ion-color-dark-rgb: 244, 245, 248;
--ion-color-dark-contrast: #000000;
--ion-color-dark-contrast-rgb: 0, 0, 0;
--ion-color-dark-shade: #d7d8da;
--ion-color-dark-tint: #f5f6f9;

--ion-color-medium: #989aa2;
--ion-color-medium-rgb: 152, 154, 162;
--ion-color-medium-contrast: #000000;
--ion-color-medium-contrast-rgb: 0, 0, 0;
--ion-color-medium-shade: #86888f;
--ion-color-medium-tint: #a2a4ab;

--ion-color-light: #222428;
--ion-color-light-rgb: 34, 36, 40;
--ion-color-light-contrast: #ffffff;
--ion-color-light-contrast-rgb: 255, 255, 255;
--ion-color-light-shade: #1e2023;
--ion-color-light-tint: #383a3e;
}

/*
* iOS Dark Theme
* -------------------------------------------
*/

.ios body.dark {
--ion-background-color: #000000;
--ion-background-color-rgb: 0, 0, 0;

--ion-text-color: #ffffff;
--ion-text-color-rgb: 255, 255, 255;

--ion-color-step-50: #0d0d0d;
--ion-color-step-100: #1a1a1a;
--ion-color-step-150: #262626;
--ion-color-step-200: #333333;
--ion-color-step-250: #404040;
--ion-color-step-300: #4d4d4d;
--ion-color-step-350: #595959;
--ion-color-step-400: #666666;
--ion-color-step-450: #737373;
--ion-color-step-500: #808080;
--ion-color-step-550: #8c8c8c;
--ion-color-step-600: #999999;
--ion-color-step-650: #a6a6a6;
--ion-color-step-700: #b3b3b3;
--ion-color-step-750: #bfbfbf;
--ion-color-step-800: #cccccc;
--ion-color-step-850: #d9d9d9;
--ion-color-step-900: #e6e6e6;
--ion-color-step-950: #f2f2f2;

--ion-item-background: #000000;

--ion-card-background: #1c1c1d;
}

.ios body.dark ion-modal {
--ion-background-color: var(--ion-color-step-100);
--ion-toolbar-background: var(--ion-color-step-150);
--ion-toolbar-border-color: var(--ion-color-step-250);
--ion-item-background: var(--ion-color-step-150);
}

/*
* Material Design Dark Theme
* -------------------------------------------
*/

.md body.dark {
--ion-background-color: #121212;
--ion-background-color-rgb: 18, 18, 18;

--ion-text-color: #ffffff;
--ion-text-color-rgb: 255, 255, 255;

--ion-border-color: #222222;

--ion-color-step-50: #1e1e1e;
--ion-color-step-100: #2a2a2a;
--ion-color-step-150: #363636;
--ion-color-step-200: #414141;
--ion-color-step-250: #4d4d4d;
--ion-color-step-300: #595959;
--ion-color-step-350: #656565;
--ion-color-step-400: #717171;
--ion-color-step-450: #7d7d7d;
--ion-color-step-500: #898989;
--ion-color-step-550: #949494;
--ion-color-step-600: #a0a0a0;
--ion-color-step-650: #acacac;
--ion-color-step-700: #b8b8b8;
--ion-color-step-750: #c4c4c4;
--ion-color-step-800: #d0d0d0;
--ion-color-step-850: #dbdbdb;
--ion-color-step-900: #e7e7e7;
--ion-color-step-950: #f3f3f3;

--ion-item-background: #1e1e1e;

--ion-toolbar-background: #1f1f1f;

--ion-tab-bar-background: #1f1f1f;

--ion-card-background: #1e1e1e;
}
</style>
</head>

<body>
<ion-app>
<ion-header>
<ion-toolbar>
<ion-title>Toggle - enableOnOffLabels</ion-title>
<ion-buttons slot="end">
<ion-button id="popover-trigger">Options</ion-button>
</ion-buttons>
<ion-popover class="options-popover" trigger="popover-trigger">
<ion-list lines="none">
<ion-item id="dark-mode">
<ion-label>Dark Mode</ion-label>
<ion-checkbox slot="end"></ion-checkbox>
</ion-item>
</ion-list>
</ion-popover>
</ion-toolbar>
</ion-header>

<ion-content>
<ion-list>
<ion-item>
<ion-label>Unchecked</ion-label>
<ion-toggle slot="end" enable-on-off-labels="true"></ion-toggle>
</ion-item>

<ion-item>
<ion-label>Checked</ion-label>
<ion-toggle slot="end" enable-on-off-labels="true" checked></ion-toggle>
</ion-item>

<ion-item>
<ion-label>Secondary Unchecked</ion-label>
<ion-toggle slot="end" color="secondary" enable-on-off-labels="true"></ion-toggle>
</ion-item>

<ion-item>
<ion-label>Secondary Checked</ion-label>
<ion-toggle slot="end" color="secondary" enable-on-off-labels="true" checked></ion-toggle>
</ion-item>

<ion-item>
<ion-label>Success Unchecked</ion-label>
<ion-toggle slot="end" color="success" enable-on-off-labels="true"></ion-toggle>
</ion-item>

<ion-item>
<ion-label>Success Checked</ion-label>
<ion-toggle slot="end" color="success" enable-on-off-labels="true" checked></ion-toggle>
</ion-item>

<ion-item>
<ion-label>Danger Unchecked</ion-label>
<ion-toggle slot="end" color="danger" enable-on-off-labels="true"></ion-toggle>
</ion-item>

<ion-item>
<ion-label>Danger Checked</ion-label>
<ion-toggle slot="end" color="danger" enable-on-off-labels="true" checked></ion-toggle>
</ion-item>

<ion-item>
<ion-label>Tertiary Unchecked</ion-label>
<ion-toggle slot="end" color="tertiary" enable-on-off-labels="true"></ion-toggle>
</ion-item>

<ion-item>
<ion-label>Tertiary Checked</ion-label>
<ion-toggle slot="end" color="tertiary" enable-on-off-labels="true" checked></ion-toggle>
</ion-item>

<ion-item>
<ion-label>Light Unchecked</ion-label>
<ion-toggle slot="end" color="light" enable-on-off-labels="true"></ion-toggle>
</ion-item>

<ion-item>
<ion-label>Light Checked</ion-label>
<ion-toggle slot="end" color="light" enable-on-off-labels="true" checked></ion-toggle>
</ion-item>

<ion-item>
<ion-label>Medium Unchecked</ion-label>
<ion-toggle slot="end" color="medium" enable-on-off-labels="true"></ion-toggle>
</ion-item>

<ion-item>
<ion-label>Medium Checked</ion-label>
<ion-toggle slot="end" color="medium" enable-on-off-labels="true" checked></ion-toggle>
</ion-item>

<ion-item>
<ion-label>Dark Unchecked</ion-label>
<ion-toggle slot="end" color="dark" enable-on-off-labels="true"></ion-toggle>
</ion-item>

<ion-item>
<ion-label>Dark Checked</ion-label>
<ion-toggle slot="end" color="dark" enable-on-off-labels="true" checked></ion-toggle>
</ion-item>
</ion-list>
</ion-content>
</ion-app>

<script>
const darkModeCheckbox = document.querySelector('ion-checkbox');
darkModeCheckbox.addEventListener('ionChange', (ev) => {
if (ev.detail.checked) {
document.body.classList.add('dark');
} else {
document.body.classList.remove('dark');
}
});
</script>
</body>
</html>
32 changes: 32 additions & 0 deletions core/src/components/toggle/test/enable-on-off-labels/toggle.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';

test.describe('toggle: enableOnOffLabels', () => {
test.beforeEach(async ({ page }) => {
await page.goto(`/src/components/toggle/test/enable-on-off-labels`);
});

test('should not have visual regressions', async ({ page }) => {
await page.setIonViewport();

expect(await page.screenshot()).toMatchSnapshot(`toggle-on-off-labels-diff-${page.getSnapshotSettings()}.png`);
});

test.describe('dark mode', () => {
test('should not have visual regressions', async ({ page }) => {
const ionPopoverDidPresent = await page.spyOnEvent('ionPopoverDidPresent');

await page.click('#popover-trigger');
await ionPopoverDidPresent.next();

await page.click('#dark-mode');
sean-perkins marked this conversation as resolved.
Show resolved Hide resolved
await page.waitForChanges();

await page.setIonViewport();

expect(await page.screenshot()).toMatchSnapshot(
`toggle-on-off-labels-dark-mode-diff-${page.getSnapshotSettings()}.png`
);
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading