diff --git a/_dev/src/scss/_variables.scss b/_dev/src/scss/_variables.scss index ed8d16ef2..592754694 100644 --- a/_dev/src/scss/_variables.scss +++ b/_dev/src/scss/_variables.scss @@ -47,6 +47,7 @@ $cdk-prefix: "cdk-"; --#{$cdk-prefix}font-family-material-icons, "Material Icons" ); + --#{$ua-prefix}default-transition-duration: var(--#{$cdk-prefix}default-transition-duration, 0.15s); } /* 1.7.8.0 */ diff --git a/_dev/src/scss/components/form/_switch.scss b/_dev/src/scss/components/form/_switch.scss index ceb44c504..913f7b68f 100644 --- a/_dev/src/scss/components/form/_switch.scss +++ b/_dev/src/scss/components/form/_switch.scss @@ -1,76 +1,92 @@ @use "../../variables" as *; -$e: ".prestashop-switch"; +$e: ".ua-switch"; #{$ua-id} { #{$e} { - display: flex; - gap: 1rem; - align-items: center; - margin: 0; - background-color: transparent; - box-shadow: none; + --#{$ua-prefix}switch-background-color: var(--#{$ua-prefix}primary-700); + --#{$ua-prefix}switch-checked-background-color: var(--#{$ua-prefix}green-500); + --#{$ua-prefix}switch-outline-color: var(--#{$ua-prefix}blue-500); + position: relative; - // Custom switch ugly harmonization - input { - inset: 0; - z-index: 1; + &__label { + display: flex; + flex-direction: row-reverse; + gap: 1rem; + align-items: center; margin: 0; cursor: pointer; - &:checked { - z-index: 0; - } - - &:first-of-type:checked ~ label:first-of-type { - display: block; - } - - &:last-of-type:checked ~ label:last-of-type { - display: block; - } - - &:first-of-type:checked ~ .slide-button::after { - transform: translateX(0.875rem); + &:active { + #{$e}__slider { + outline: 2px solid var(--#{$ua-prefix}switch-outline-color); + } } } - - label { - position: static; - inset: auto; + + &__yes { display: none; - height: auto; - padding: 0; - margin: 0; - font-weight: 500; - color: var(--#{$ua-prefix}base-text-color); - pointer-events: none; - transform: none; } - .slide-button { + &__no { + display: flex; + } + + &__slider { position: relative; - inset: auto; - z-index: 0; - display: block; - flex-shrink: 0; width: 2.25rem; - height: 1.375rem; - padding: 0.5rem 1rem; - border: none; - border-radius: 999px; - transform: none; + height: 1.25rem; + background-color: var(--#{$ua-prefix}switch-background-color); + border-radius: 0.625rem; + cursor: pointer; + transition: background-color var(--#{$ua-prefix}default-transition-duration); - &::after { + &::before { content: ""; position: absolute; - top: 0.125rem; + bottom: 0.125rem; left: 0.125rem; - width: 1.125rem; - height: 1.125rem; - background: var(--#{$ua-prefix}white); - border-radius: 999px; - transform: none; + width: 1rem; + height: 1rem; + background-color: var(--#{$ua-prefix}white); + border-radius: 50%; + transition: transform var(--#{$ua-prefix}default-transition-duration); + } + } + + &__input { + position: absolute; + width: 0; + height: 0; + + &:checked { + + #{$e}__label { + #{$e}__slider { + background-color: var(--#{$ua-prefix}switch-checked-background-color); + + &::before { + transform: translateX(1rem); + } + } + + #{$e}__yes { + display: flex; + } + + #{$e}__no { + display: none; + } + } + } + + &:active, + &:focus, + &:focus-visible { + + #{$e}__label { + #{$e}__slider { + outline: 2px solid var(--#{$ua-prefix}switch-outline-color); + } + } } } } diff --git a/storybook/stories/components/RenderBool.stories.js b/storybook/stories/components/RenderBool.stories.js index 653d797b0..62013a952 100644 --- a/storybook/stories/components/RenderBool.stories.js +++ b/storybook/stories/components/RenderBool.stories.js @@ -31,7 +31,16 @@ export default { argTypes: { type: { control: 'select', - options: ['disabled', 'bool', 'radio', 'select', 'textarea', 'container', 'container_end', 'text'], + options: [ + "disabled", + "bool", + "radio", + "select", + "textarea", + "container", + "container_end", + "text", + ], defaultValue: 'bool', }, }, @@ -40,15 +49,12 @@ export default { id: "deactivate_modules", title: "Deactivate non-native modules", desc: "All the modules installed after creating your store are considered non-native modules. They might be incompatible with the new version of PrestaShop. We recommend deactivating them during the update.", - js: { - on: 'onclick="enableFeature()"', - off: 'onclick="disableFeature()"', - }, type: 'bool', required: true, disabled: true, }, - key: "PS_AUTOUP_CUSTOM_MOD_DESACT", + BoolName: "PS_AUTOUP_CUSTOM_MOD_DESACT", + BoolId: "PS_AUTOUP_CUSTOM_MOD_DESACT", val: true, }, }; diff --git a/views/templates/components/render-bool.html.twig b/views/templates/components/render-bool.html.twig index a90b12e3a..a34af46e7 100644 --- a/views/templates/components/render-bool.html.twig +++ b/views/templates/components/render-bool.html.twig @@ -1,31 +1,25 @@ {% extends "@ModuleAutoUpgrade/components/render-field.html.twig" %} {% block action_content %} - - - - - - - +