import Emitter from '../../../mixins/emitter'
+import withapp from '../../../mixins/withapp'
+import themeable from '../../../mixins/themeable'
export default {
name: 'NSwitch',
- mixins: [ Emitter ],
+ mixins: [ withapp, themeable, Emitter ],
inject: {
formItem: {
default: null
diff --git a/packages/common/Tooltip/src/main.vue b/packages/common/Tooltip/src/main.vue
index c28c74153..43aa2a0a2 100644
--- a/packages/common/Tooltip/src/main.vue
+++ b/packages/common/Tooltip/src/main.vue
@@ -55,6 +55,10 @@ export default {
maxWidth: {
type: Number,
default: null
+ },
+ controller: {
+ type: Object,
+ default: null
}
},
render (h, context) {
diff --git a/styles/Switch.scss b/styles/Switch.scss
index a3474158e..1c3335c51 100644
--- a/styles/Switch.scss
+++ b/styles/Switch.scss
@@ -1,62 +1,79 @@
@import './mixins/mixins.scss';
@import './themes/vars.scss';
-@include b(switch) {
- display: inline-block;
- @include e(rail) {
- cursor: pointer;
- position: relative;
- height: 14px;
- width: 30px;
- border-radius: 7px;
- background-color: rgba(148,151,155,0.4);
- margin: 3px;
- transition: background-color .2s $default-cubic-bezier;
- &::before, &::after {
- cursor: inherit;
- content: "";
- position: absolute;
- height: 20px;
- width: 24px;
- max-width: 20px;
- border-radius: 10px;
- top: -3px;
- left: -3px;
- box-shadow:0px 2px 4px 0px rgba(0,0,0,0.4);
- transition: left .2s $default-cubic-bezier, opacity .2s $default-cubic-bezier, max-width .2s $default-cubic-bezier;
+@include themes-mixin{
+ @include b(switch) {
+ @include once {
+ display: inline-block;
}
- @include not-m(disabled) {
- &:active::before, &:active::after {
- max-width: 24px;
- }
- @include m(active) {
- &:active::before, &:active::after {
- left: 9px;
+ @include e(rail) {
+ @include once {
+ cursor: pointer;
+ position: relative;
+ height: 14px;
+ width: 30px;
+ border-radius: 7px;
+ margin: 3px;
+ transition: background-color .2s $default-cubic-bezier;
+ &::before, &::after {
+ box-sizing: border-box;
+ cursor: inherit;
+ content: "";
+ position: absolute;
+ height: 20px;
+ width: 24px;
+ max-width: 20px;
+ border-radius: 10px;
+ top: -3px;
+ left: -3px;
+ // transition: left .2s $default-cubic-bezier, opacity .2s $default-cubic-bezier, max-width .2s $default-cubic-bezier;
+ }
+ &::before {
+ opacity: 1;
+ }
+ &::after {
+ opacity: 0;
+ }
+ @include not-m(disabled) {
+ &:active::before, &:active::after {
+ max-width: 24px;
+ }
+ @include m(active) {
+ &:active::before, &:active::after {
+ left: 9px;
+ }
+ }
+ }
+ @include m(active) {
+ &::before {
+ left: 13px;
+ opacity: 1;
+ }
+ &::after {
+ left: 13px;
+ opacity: 1;
+ }
}
}
- }
- &::before {
- background-image: linear-gradient(52deg,rgba(148,151,155,1) 0%,rgba(148,151,155,1) 100%);
- opacity: 1;
- }
- &::after {
- background-image: linear-gradient(52deg,rgba(120,205,104,1) 0%,rgba(20,166,165,1) 100%);
- opacity: 0;
- }
- @include m(active) {
- background-color: rgba(97, 196, 118, .27);
+ &::before, &::after {
+ box-shadow: $--switch-switcher-box-shadow;
+ transition: $--switch-switcher-transition;
+ // border: $--switch-switcher-border;
+ }
+ background-color: map-get($map: $--switch-rail-background-color, $key: 'inactive');
&::before {
- left: 13px;
- opacity: 0;
+ background-image: map-get($map: $--switch-switcher-color, $key: 'inactive');
}
&::after {
- left: 13px;
- opacity: 1;
+ background-image: map-get($map: $--switch-switcher-color, $key: 'active');
+ }
+ @include m(active) {
+ background-color: map-get($map: $--switch-rail-background-color, $key: 'active');
+ }
+ @include m(disabled) {
+ cursor: not-allowed;
+ opacity: .5;
}
}
- @include m(disabled) {
- cursor: not-allowed;
- opacity: .5;
- }
}
-}
\ No newline at end of file
+}
diff --git a/styles/themes/dark/components/Switch.scss b/styles/themes/dark/components/Switch.scss
new file mode 100644
index 000000000..32188586e
--- /dev/null
+++ b/styles/themes/dark/components/Switch.scss
@@ -0,0 +1,13 @@
+@mixin setup-dark-switch {
+ $--switch-rail-background-color: (
+ "inactive": rgba(148,151,155,0.4),
+ "active": change-color($--n-primary-color, $alpha: .25)
+ )!global;
+ $--switch-switcher-color: (
+ "inactive": linear-gradient(52deg,rgba(148,151,155,1) 0%,rgba(148,151,155,1) 100%),
+ "active": linear-gradient(52deg,rgba(120,205,104,1) 0%,rgba(20,166,165,1) 100%)
+ ) !global;
+ $--switch-switcher-box-shadow: 0px 2px 4px 0px rgba(0,0,0,0.4) !global;
+ $--switch-switcher-border: 1px solid transparent !global;
+ $--switch-switcher-transition: (left .2s $default-cubic-bezier, opacity .2s $default-cubic-bezier, max-width .2s $default-cubic-bezier) !global;
+}
\ No newline at end of file
diff --git a/styles/themes/dark/index.scss b/styles/themes/dark/index.scss
index 840d8aa91..2d5b7ef1f 100644
--- a/styles/themes/dark/index.scss
+++ b/styles/themes/dark/index.scss
@@ -10,6 +10,7 @@
@import "components/Popover.scss";
@import "components/Tooltip.scss";
@import "components/Confirm.scss";
+@import "components/Switch.scss";
@mixin setup-dark-theme () {
@include setup-dark-colors();
@@ -47,4 +48,5 @@
@include setup-dark-popover;
@include setup-dark-tooltip;
@include setup-dark-confirm;
+ @include setup-dark-switch;
}
\ No newline at end of file
diff --git a/styles/themes/light/components/Switch.scss b/styles/themes/light/components/Switch.scss
new file mode 100644
index 000000000..194295feb
--- /dev/null
+++ b/styles/themes/light/components/Switch.scss
@@ -0,0 +1,13 @@
+@mixin setup-light-switch {
+ $--switch-rail-background-color:(
+ "inactive": $--n-divider-color,
+ "active": $--n-primary-color
+ ) !global;
+ $--switch-switcher-color: (
+ "inactive": linear-gradient(52deg,rgba(255,255,255,1) 0%,rgba(255,255,255,1) 100%),
+ "active": linear-gradient(52deg,rgba(255,255,255,1) 0%,rgba(255,255,255,1) 100%),
+ ) !global;
+ $--switch-switcher-box-shadow: (0px 1px 4px 0px rgba(0,0,0,0.35), inset 0px 0px 1px 0px rgba(0,0,0,0.05)) !global;
+ $--switch-switcher-border: 1px solid $--n-divider-color !global;
+ $--switch-switcher-transition: (left .2s $default-cubic-bezier, max-width .2s $default-cubic-bezier) !global;
+}
\ No newline at end of file
diff --git a/styles/themes/light/index.scss b/styles/themes/light/index.scss
index a5d69d722..b6f3cb1c0 100644
--- a/styles/themes/light/index.scss
+++ b/styles/themes/light/index.scss
@@ -10,6 +10,7 @@
@import "components/Popover.scss";
@import "components/Tooltip.scss";
@import "components/Confirm.scss";
+@import "components/Switch.scss";
@mixin setup-light-theme () {
@include setup-light-colors();
@@ -43,4 +44,5 @@
@include setup-light-popover;
@include setup-light-tooltip;
@include setup-light-confirm;
+ @include setup-light-switch;
}
\ No newline at end of file