From 1d1ea6a0cbc1265a6303d7dc49d43b3486782fb2 Mon Sep 17 00:00:00 2001 From: Cagatay Civici Date: Sat, 17 Feb 2024 14:56:52 +0300 Subject: [PATCH] Migrated input switch --- components/lib/theme/aura/index.js | 2 + .../lib/theme/aura/inputswitch/index.js | 128 ++++++++++++++++++ .../lib/theme/aura/inputswitch/package.json | 0 3 files changed, 130 insertions(+) create mode 100644 components/lib/theme/aura/inputswitch/index.js create mode 100644 components/lib/theme/aura/inputswitch/package.json diff --git a/components/lib/theme/aura/index.js b/components/lib/theme/aura/index.js index 2a31c9d8a..9d363a4ef 100644 --- a/components/lib/theme/aura/index.js +++ b/components/lib/theme/aura/index.js @@ -21,6 +21,7 @@ import global from 'primevue/theme/aura/global'; import image from 'primevue/theme/aura/image'; import inlinemessage from 'primevue/theme/aura/inlinemessage'; import inplace from 'primevue/theme/aura/inplace'; +import inputswitch from 'primevue/theme/aura/inputswitch'; import megamenu from 'primevue/theme/aura/megamenu'; import menu from 'primevue/theme/aura/menu'; import menubar from 'primevue/theme/aura/menubar'; @@ -201,6 +202,7 @@ export default { image, inlinemessage, inplace, + inputswitch, orderlist, organizationchart, overlaypanel, diff --git a/components/lib/theme/aura/inputswitch/index.js b/components/lib/theme/aura/inputswitch/index.js new file mode 100644 index 000000000..d03410c00 --- /dev/null +++ b/components/lib/theme/aura/inputswitch/index.js @@ -0,0 +1,128 @@ +export default { + variables: { + colorScheme: { + light: { + root: { + background: '{surface.300}', + backgroundInvalid: '{red.400}', + backgroundHover: '{surface.400}', + backgroundChecked: '{primary.500}', + backgroundHoverChecked: '{primary.600}', + borderRadius: '30px' + }, + handle: { + background: '{surface.0}', + backgroundHover: '{surface.0}', + backgroundChecked: '{surface.0}', + backgroundHoverChecked: '{surface.0}', + backgroundInvalid: '{surface.0}' + } + }, + dark: { + root: { + background: '{surface.700}', + backgroundInvalid: '{red.300}', + backgroundHover: '{surface.600}', + backgroundChecked: '{primary.400}', + backgroundHoverChecked: '{primary.300}', + borderRadius: '30px' + }, + handle: { + background: '{surface.400}', + backgroundHover: '{surface.300}', + backgroundChecked: '{surface.900}', + backgroundHoverChecked: '{surface.900}', + backgroundInvalid: '{surface.900}' + } + } + } + }, + css: ` +.p-inputswitch { + display: inline-block; + width: 2.5rem; + height: 1.5rem; +} + +.p-inputswitch-input { + cursor: pointer; + appearance: none; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + padding: 0; + margin: 0; + opacity: 0; + z-index: 1; + outline: 0 none; + border-radius: var(--p-inputswitch-border-radius); +} + +.p-inputswitch-slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + border: 0 none; + background: var(--p-inputswitch-background); + transition: background-color var(--p-transition-duration), color var(--p-transition-duration), border-color var(--p-transition-duration), box-shadow var(--p-transition-duration), outline-color var(--p-transition-duration); + border-radius: var(--p-inputswitch-border-radius); + outline-color: transparent; +} + +.p-inputswitch-slider:before { + position: absolute; + content: ""; + top: 50%; + background: var(--p-inputswitch-handle-background); + width: 1rem; + height: 1rem; + left: 0.25rem; + margin-top: -0.5rem; + border-radius: 50%; + transition: all var(--p-transition-duration); +} + +.p-inputswitch.p-highlight .p-inputswitch-slider { + background: var(--p-inputswitch-background-checked); +} + +.p-inputswitch.p-highlight .p-inputswitch-slider:before { + background: var(--p-inputswitch-handle-background-checked); + left: 1.25rem; +} + +.p-inputswitch:not(.p-disabled):has(.p-inputswitch-input:hover) .p-inputswitch-slider { + background: var(--p-inputswitch-background-hover); +} + +.p-inputswitch:not(.p-disabled):has(.p-inputswitch-input:hover) .p-inputswitch-slider:before { + background: var(--p-inputswitch-handle-background-hover); +} + +.p-inputswitch:not(.p-disabled):has(.p-inputswitch-input:hover).p-highlight .p-inputswitch-slider { + background: var(--p-inputswitch-background-hover-checked); +} + +.p-inputswitch:not(.p-disabled):has(.p-inputswitch-input:hover).p-highlight .p-inputswitch-slider:before { + background: var(--p-inputswitch-handle-background-hover-checked); +} + +.p-inputswitch:not(.p-disabled):has(.p-inputswitch-input:focus-visible) .p-inputswitch-slider { + outline: var(--p-focus-ring-width) var(--p-focus-ring-style) var(--p-focus-ring-color); + outline-offset: var(--p-focus-ring-offset); +} + +.p-inputswitch.p-invalid > .p-inputswitch-slider { + background: var(--p-inputswitch-background-invalid); +} + +.p-inputswitch.p-invalid > .p-inputswitch-slider:before { + background: var(--p-inputswitch-handle-background-invalid); +} +` +}; diff --git a/components/lib/theme/aura/inputswitch/package.json b/components/lib/theme/aura/inputswitch/package.json new file mode 100644 index 000000000..e69de29bb