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

fix(core): checkbox changes to match design #187

Merged
merged 6 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 18 additions & 16 deletions packages/core/scss/components/_checkboxes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

@mixin checkbox-basic() {
$size: $large-space;
$size: 1.125rem;

/* Base for label styling */
[type='checkbox']:not(:checked),
Expand All @@ -28,7 +28,9 @@
[type='checkbox']:not(:checked) + label,
[type='checkbox']:checked + label {
position: relative;
line-height: $size;
display: flex;
align-items: center;
line-height: $default-space;
user-select: none;

color: var(--theme-checkbox-label--color);
Expand All @@ -52,14 +54,14 @@

[type='checkbox'] + label:focus-visible {
&:before {
outline: 1px solid var(--focus--border-color);
outline: 0.0625rem solid var(--focus--border-color);
outline-offset: var(--theme-checkbox--focus--outline-offset);
}
}

[type='checkbox']:focus-visible + label {
&:before {
outline: 1px solid var(--focus--border-color);
outline: 0.0625rem solid var(--focus--border-color);
outline-offset: var(--theme-checkbox--focus--outline-offset);
}
}
Expand Down Expand Up @@ -99,17 +101,17 @@

& + label:after {
content: '';
width: 9px;
height: 4px;
width: 0.45rem;
height: 0.25rem;
display: block;
border-top: none;
border-right: none;
border-bottom: 1px solid var(--theme-checkbox-checked--color);
border-left: 1px solid var(--theme-checkbox-checked--color);
border-bottom: 0.0625rem solid var(--theme-checkbox-checked--color);
border-left: 0.0625rem solid var(--theme-checkbox-checked--color);
position: absolute;
top: 8px;
left: 8px;
transform: rotate(-45deg) scale(2);
top: 0.3rem;
left: 0.35rem;
transform: rotate(-53deg) scale(2);
}

&:hover + label:before {
Expand Down Expand Up @@ -144,12 +146,12 @@
& + label:after {
content: '';
display: block;
width: 14px;
height: 1px;
border-bottom: 2px solid var(--theme-checkbox-mixed--color);
width: 0.625rem;
height: 0.125rem;
border-bottom: 0.125rem solid var(--theme-checkbox-mixed--color);
position: absolute;
top: 11px;
left: 5px;
top: $small-space;
left: $tiny-space;
}

& + label:before {
Expand Down
38 changes: 38 additions & 0 deletions packages/core/src/components/checkbox/test/basic/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!--
SPDX-FileCopyrightText: 2022 Siemens AG

SPDX-License-Identifier: MIT
-->

<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0"
/>
<title>Stencil Component Starter</title>
</head>
<body>
<div style="margin-bottom: 1rem">
<input type="checkbox" id="checkbox_01" checked />
<label for="checkbox_01">Simple checkbox</label>
</div>

<div style="margin-bottom: 1rem">
<input type="checkbox" id="checkbox_02" checked disabled />
<label for="checkbox_02">Disabled checkbox</label>
</div>

<div style="margin-bottom: 1rem">
<input type="checkbox" id="checkbox_01" />
<label for="checkbox_01">Simple checkbox</label>
</div>

<div>
<input type="checkbox" id="checkbox_02" disabled />
<label for="checkbox_02">Disabled checkbox</label>
</div>
<script src="http://127.0.0.1:8080/scripts/e2e/load-e2e-runtime.js"></script>
</body>
</html>
23 changes: 23 additions & 0 deletions packages/core/src/components/checkbox/test/checkbox.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* SPDX-FileCopyrightText: 2022 Siemens AG
*
* SPDX-License-Identifier: MIT
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import { expect } from '@playwright/test';
import { regressionTest } from '@utils/test';

regressionTest.describe('checkbox', () => {
regressionTest('basic', async ({ page }) => {
await page.goto(`checkbox/test/basic`);
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot();
});

regressionTest('indeterminate', async ({ page }) => {
await page.goto(`checkbox/test/indeterminate`);
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot();
});
});
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!--
SPDX-FileCopyrightText: 2022 Siemens AG

SPDX-License-Identifier: MIT
-->

<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0"
/>
<title>Stencil Component Starter</title>
</head>
<body>
<div>
<input type="checkbox" id="checkbox_01" />
<label for="checkbox_01">Simple checkbox</label>
</div>
<script>
(function () {
const checkbox = document.querySelector('#checkbox_01');
checkbox.indeterminate = true;
})();
</script>
<script src="http://127.0.0.1:8080/scripts/e2e/load-e2e-runtime.js"></script>
</body>
</html>