Skip to content
Snippets Groups Projects
Verified Commit 198d2481 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

fix: toggle-switch layout and text #170

parent 0ad9f755
No related branches found
No related tags found
No related merge requests found
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
<script id="translations" type="application/json" data-monster-role="translations"> <script id="translations" type="application/json" data-monster-role="translations">
{ {
"toggle-switch-on": "an", "toggle-switch-on": "das ist ein wert für an",
"toggle-switch-off": "aus" "toggle-switch-off": "und für aus baumhaus"
} }
</script> </script>
...@@ -28,7 +28,10 @@ ...@@ -28,7 +28,10 @@
<div class="container"> <div class="container">
<form class="monster-form"> <form class="monster-form">
<label>monster-switch <label>monster-switch
<monster-toggle-switch id="monsterToggleSwitch" name="agb" ></monster-toggle-switch> <div style="display: inline-block;width: 200px"><monster-toggle-switch id="monsterToggleSwitch" name="agb" ></monster-toggle-switch></div>
</label>
<label>monster-switch
<input type="text" id="monsterToggleSwitch2" name="agb" />
</label> </label>
<button>Submit</button> <button>Submit</button>
</form> </form>
......
@import"../../source/components/style/mixin/form.pcss"; @import"../../source/components/style/mixin/form.pcss";
.container{
font-size: 12px;
display: flex;
flex-direction: column;
}
...@@ -5,70 +5,79 @@ ...@@ -5,70 +5,79 @@
[data-monster-role=control] { [data-monster-role=control] {
font-family: inherit; font-family: inherit;
font-size: 100%; font-size: inherit;
padding: 0.4rem 0.6rem;
margin: 0; margin: 0;
outline: none; outline: none;
box-sizing: border-box; box-sizing: border-box;
}
[data-monster-role=control]:focus { &:focus {
outline: 1px dashed var(--monster-color-selection-3); outline: 1px dashed var(--monster-color-selection-3);
outline-offset: 2px; outline-offset: 2px;
} }
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
& .switch {
position: relative;
height: 2.5em;
border-color: var(--monster-bg-color-primary-3); border-color: var(--monster-bg-color-primary-3);
border-width: thin; border-width: thin;
border-style: var(--monster-border-style); border-style: var(--monster-border-style);
transition: background-color 0.2s; transition: background-color 0.2s;
display: grid; display: inline-grid;
grid-template-columns: 1fr 1fr; grid-template-columns: 1fr 1fr;
box-sizing: border-box;
width: 100%;
} }
.switch-radio input[type="radio"] { & .switch-radio input[type="radio"] {
display: none; display: none;
} }
.label{ & .label {
height: 34px; max-width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
height: 2.5em;
display: block; display: block;
text-align: center; text-align: center;
line-height: 34px; line-height: 2.5em;
user-select: none; user-select: none;
padding: 0 0.2em;
} }
.switch-slider { & .switch-slider {
position: absolute; position: absolute;
top: 4px; top: 4px;
bottom: 4px; bottom: 4px;
left: 4px; left: 4px;
right: 28px; right: 4px;
width: calc(50% - 4px);
background-color: var(--monster-bg-color-primary-4); background-color: var(--monster-bg-color-primary-4);
transition: 0.2s; transition: 0.2s;
} }
.switch[data-monster-state="on"] .label.off { & .switch[data-monster-state="on"] .label.off {
visibility: hidden; visibility: hidden;
} }
.switch[data-monster-state="on"] .label.on {
& .switch[data-monster-state="on"] .label.on {
visibility: visible; visibility: visible;
} }
.switch[data-monster-state="off"] .label.off {
& .switch[data-monster-state="off"] .label.off {
visibility: visible; visibility: visible;
} }
.switch[data-monster-state="off"] .label.on {
& .switch[data-monster-state="off"] .label.on {
visibility: hidden; visibility: hidden;
} }
.switch[data-monster-state="on"] .switch-slider { & .switch[data-monster-state="on"] .switch-slider {
transform: translateX(24px); transform: translateX(100%);
} }
}
This diff is collapsed.
...@@ -186,7 +186,7 @@ class ToggleSwitch extends CustomControl { ...@@ -186,7 +186,7 @@ class ToggleSwitch extends CustomControl {
* *
* @return {function} * @return {function}
*/ */
[updaterTransformerMethodsSymbol]() {; [updaterTransformerMethodsSymbol]() {
return { return {
"state-callback": (Wert) => { "state-callback": (Wert) => {
return this.state; return this.state;
...@@ -195,7 +195,7 @@ class ToggleSwitch extends CustomControl { ...@@ -195,7 +195,7 @@ class ToggleSwitch extends CustomControl {
} }
/** /**
* @return [ToggleSwitchStyleSheet] * @return [CSSStyleSheet]
*/ */
static getCSSStyleSheet() { static getCSSStyleSheet() {
return [ToggleSwitchStyleSheet]; return [ToggleSwitchStyleSheet];
...@@ -417,13 +417,12 @@ function getTemplate() { ...@@ -417,13 +417,12 @@ function getTemplate() {
// language=HTML // language=HTML
return ` return `
<div data-monster-role="control" part="control" tabindex="0"> <div data-monster-role="control" part="control" tabindex="0">
<div class="switch" data-monster-role="switch"
<div class="switch" data-monster-role="switch" data-monster-attributes="data-monster-state path:value | call:state-callback " > data-monster-attributes="data-monster-state path:value | call:state-callback">
<div class="label on" data-monster-replace="path:labels.toggle-switch-on"></div> <div class="label on" data-monster-replace="path:labels.toggle-switch-on"></div>
<div class="label off" data-monster-replace="path:labels.toggle-switch-off"></div> <div class="label off" data-monster-replace="path:labels.toggle-switch-off"></div>
<div class="switch-slider"></div> <div class="switch-slider"></div>
</div> </div>
</div>`; </div>`;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment