From b0aeeda5295ec6a469ac4854bb9f4ea9dee87521 Mon Sep 17 00:00:00 2001 From: haibo tang Date: Mon, 7 Sep 2020 21:23:51 +0800 Subject: [PATCH] feat(popover): css in js --- src/Popover/index.js | 7 - src/Tooltip/src/main.js | 2 +- src/_styles/Popover.scss | 526 +++++++++--------- src/_styles/index.scss | 4 +- .../src/HeaderButton/FilterButton.vue | 2 +- src/dropdown/src/Dropdown.vue | 2 +- src/index.js | 6 +- src/menu/src/Submenu.vue | 2 +- src/popconfirm/src/Popconfirm.vue | 2 +- src/popover/index.js | 7 + .../src/main.js => popover/src/Popover.js} | 2 +- .../src/PopoverContent.js | 11 +- .../src/PopoverManager.js | 0 .../src/activatorMixin.js | 0 src/popover/src/styles/index.js | 9 + src/popover/src/styles/themed-base.cssr.js | 233 ++++++++ src/popover/styles/_common.js | 3 + src/popover/styles/dark.js | 26 + src/popover/styles/light.js | 26 + src/popselect/src/Popselect.vue | 2 +- 20 files changed, 592 insertions(+), 280 deletions(-) delete mode 100644 src/Popover/index.js create mode 100644 src/popover/index.js rename src/{Popover/src/main.js => popover/src/Popover.js} (99%) rename src/{Popover => popover}/src/PopoverContent.js (97%) rename src/{Popover => popover}/src/PopoverManager.js (100%) rename src/{Popover => popover}/src/activatorMixin.js (100%) create mode 100644 src/popover/src/styles/index.js create mode 100644 src/popover/src/styles/themed-base.cssr.js create mode 100644 src/popover/styles/_common.js create mode 100644 src/popover/styles/dark.js create mode 100644 src/popover/styles/light.js diff --git a/src/Popover/index.js b/src/Popover/index.js deleted file mode 100644 index d62fb6e42..000000000 --- a/src/Popover/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import NPopover from './src/main' - -NPopover.install = function (Vue) { - Vue.component(NPopover.name, NPopover) -} - -export default NPopover diff --git a/src/Tooltip/src/main.js b/src/Tooltip/src/main.js index 55e4d6166..6c6a95776 100644 --- a/src/Tooltip/src/main.js +++ b/src/Tooltip/src/main.js @@ -1,7 +1,7 @@ /** * Tooltip: popover wearing waistcoat */ -import NPopover from '../../Popover' +import NPopover from '../../popover' export default { name: 'NTooltip', diff --git a/src/_styles/Popover.scss b/src/_styles/Popover.scss index f11730c5d..de40b4764 100644 --- a/src/_styles/Popover.scss +++ b/src/_styles/Popover.scss @@ -1,265 +1,265 @@ -@import "./mixins/mixins.scss"; +// @import "./mixins/mixins.scss"; -@mixin popover-content-transition { - &#{&}-transition-enter-to, &#{&}-transition-leave { - transform: $--n-transform-debounce-scale; - opacity: 1; - } - &#{&}-transition-enter, &#{&}-transition-leave-to { - opacity: 0; - transform: scale(.85); - } - &#{&}-transition-enter-active { - transition: opacity .15s $--n-ease-out-cubic-bezier, transform .15s $--n-ease-out-cubic-bezier; - } - &#{&}-transition-leave-active { - transition: opacity .15s $--n-ease-in-cubic-bezier, transform .15s $--n-ease-in-cubic-bezier; - } -} +// @mixin popover-content-transition { +// &#{&}-transition-enter-to, &#{&}-transition-leave { +// transform: $--n-transform-debounce-scale; +// opacity: 1; +// } +// &#{&}-transition-enter, &#{&}-transition-leave-to { +// opacity: 0; +// transform: scale(.85); +// } +// &#{&}-transition-enter-active { +// transition: opacity .15s $--n-ease-out-cubic-bezier, transform .15s $--n-ease-out-cubic-bezier; +// } +// &#{&}-transition-leave-active { +// transition: opacity .15s $--n-ease-in-cubic-bezier, transform .15s $--n-ease-in-cubic-bezier; +// } +// } -@include themes-mixin { - @include b(popover-content) { - @include once { - @include popover-content-transition; - transition: - background-color .3s $--n-ease-in-out-cubic-bezier, - color .3s $--n-ease-in-out-cubic-bezier; - transform-origin: inherit; - transform: $--n-transform-debounce-scale; - position: relative; - font-size: 13px; - @include m(styled) { - border-radius: $--n-popover-border-radius; - padding: 8px 14px; - } - @include m(fix-width) { - white-space: normal; - width: max-content; - box-sizing: border-box; - } - @include b(popover-arrow-wrapper) { - position: absolute; - overflow: hidden; - pointer-events: none; - @include b(popover-arrow) { - transition: background-color .3s $--n-ease-in-out-cubic-bezier; - position: absolute; - display: block; - width: $--n-popover-arrow-width * 2; - height: $--n-popover-arrow-width * 2; - box-shadow: $--n-popover-arrow-box-shadow; - transform: rotate(45deg); - } - } - @include m(no-arrow) { - &[n-placement$="top-start"] { - margin-bottom: 6px; - } - &[n-placement$="top"] { - margin-bottom: 6px; - } - &[n-placement$="top-end"] { - margin-bottom: 6px; - } - &[n-placement$="bottom-start"] { - margin-top: 6px; - } - &[n-placement$="bottom"] { - margin-top: 6px; - } - &[n-placement$="bottom-end"] { - margin-top: 6px; - } - &[n-placement$="left-start"] { - margin-right: 6px; - }&[n-placement$="left"] { - margin-right: 6px; - } - &[n-placement$="left-end"] { - margin-right: 6px; - } - &[n-placement$="right-start"] { - margin-left: 6px; - } - &[n-placement$="right"] { - margin-left: 6px; - } - &[n-placement$="right-end"] { - margin-left: 6px; - } - } - &[n-placement$="top-start"] { - margin-bottom: 10px; - @include b(popover-arrow-wrapper) { - right: 0; - left: 0; - top: 100%; - height: $--n-popover-arrow-width * 2; - @include b(popover-arrow) { - top: -$--n-popover-arrow-width; - left: 10px; - } - } - } - &[n-placement$="top"] { - margin-bottom: 10px; - @include b(popover-arrow-wrapper) { - right: 0; - left: 0; - top: 100%; - height: $--n-popover-arrow-width * 2; - @include b(popover-arrow) { - top: -$--n-popover-arrow-width; - transform: translateX(-$--n-popover-arrow-width) rotate(45deg) ; - left: 50%; - } - } - } - &[n-placement$="top-end"] { - margin-bottom: 10px; - @include b(popover-arrow-wrapper) { - right: 0; - left: 0; - top: 100%; - height: $--n-popover-arrow-width * 2; - @include b(popover-arrow) { - top: -$--n-popover-arrow-width; - right: 10px; - } - } - } - &[n-placement$="bottom-start"] { - margin-top: 10px; - @include b(popover-arrow-wrapper) { - right: 0; - left: 0; - bottom: 100%; - height: $--n-popover-arrow-width * 2; - @include b(popover-arrow) { - bottom: -$--n-popover-arrow-width; - left: 10px; - } - } - } - &[n-placement$="bottom"] { - margin-top: 10px; - @include b(popover-arrow-wrapper) { - right: 0; - left: 0; - bottom: 100%; - height: $--n-popover-arrow-width * 2; - @include b(popover-arrow) { - bottom: -$--n-popover-arrow-width; - transform: translateX(-$--n-popover-arrow-width) rotate(45deg) ; - left: 50%; - } - } - } - &[n-placement$="bottom-end"] { - margin-top: 10px; - @include b(popover-arrow-wrapper) { - right: 0; - left: 0; - bottom: 100%; - height: $--n-popover-arrow-width * 2; - @include b(popover-arrow) { - bottom: -$--n-popover-arrow-width; - right: 10px; - } - } - } - &[n-placement$="left-start"] { - margin-right: 10px; - @include b(popover-arrow-wrapper) { - top: 0; - bottom: 0; - left: 100%; - width: $--n-popover-arrow-width * 2; - @include b(popover-arrow) { - left: -$--n-popover-arrow-width; - top: 10px; - } - } - } - &[n-placement$="left"] { - margin-right: 10px; - @include b(popover-arrow-wrapper) { - top: 0; - bottom: 0; - left: 100%; - width: $--n-popover-arrow-width * 2; - @include b(popover-arrow) { - left: -$--n-popover-arrow-width; - transform: translateY(-$--n-popover-arrow-width) rotate(45deg) ; - top: 50%; - } - } - } - &[n-placement$="left-end"] { - margin-right: 10px; - @include b(popover-arrow-wrapper) { - top: 0; - bottom: 0; - left: 100%; - width: $--n-popover-arrow-width * 2; - @include b(popover-arrow) { - left: -$--n-popover-arrow-width; - bottom: 10px; - } - } - } - &[n-placement$="right-start"] { - margin-left: 10px; - @include b(popover-arrow-wrapper) { - top: 0; - bottom: 0; - right: 100%; - width: $--n-popover-arrow-width * 2; - @include b(popover-arrow) { - right: -$--n-popover-arrow-width; - top: 10px; - } - } - } - &[n-placement$="right"] { - margin-left: 10px; - @include b(popover-arrow-wrapper) { - top: 0; - bottom: 0; - right: 100%; - width: $--n-popover-arrow-width * 2; - @include b(popover-arrow) { - right: -$--n-popover-arrow-width; - transform: translateY(-$--n-popover-arrow-width) rotate(45deg) ; - top: 50%; - } - } - } - &[n-placement$="right-end"] { - margin-left: 10px; - @include b(popover-arrow-wrapper) { - top: 0; - bottom: 0; - right: 100%; - width: $--n-popover-arrow-width * 2; - @include b(popover-arrow) { - right: -$--n-popover-arrow-width; - bottom: 10px; - } - } - } - } - @include m(styled) { - background-color: $--popover-background-color; - } - color: $--popover-text-color; - @include b(popover-arrow-wrapper) { - @include b(popover-arrow) { - background-color: $--popover-background-color; - } - } - @include m(shadow) { - box-shadow: $--popover-box-shadow; - } - } -} +// @include themes-mixin { +// @include b(popover-content) { +// @include once { +// @include popover-content-transition; +// transition: +// background-color .3s $--n-ease-in-out-cubic-bezier, +// color .3s $--n-ease-in-out-cubic-bezier; +// transform-origin: inherit; +// transform: $--n-transform-debounce-scale; +// position: relative; +// font-size: 13px; +// @include m(styled) { +// border-radius: $--n-popover-border-radius; +// padding: 8px 14px; +// } +// @include m(fix-width) { +// white-space: normal; +// width: max-content; +// box-sizing: border-box; +// } +// @include b(popover-arrow-wrapper) { +// position: absolute; +// overflow: hidden; +// pointer-events: none; +// @include b(popover-arrow) { +// transition: background-color .3s $--n-ease-in-out-cubic-bezier; +// position: absolute; +// display: block; +// width: $--n-popover-arrow-width * 2; +// height: $--n-popover-arrow-width * 2; +// box-shadow: $--n-popover-arrow-box-shadow; +// transform: rotate(45deg); +// } +// } +// @include m(no-arrow) { +// &[n-placement$="top-start"] { +// margin-bottom: 6px; +// } +// &[n-placement$="top"] { +// margin-bottom: 6px; +// } +// &[n-placement$="top-end"] { +// margin-bottom: 6px; +// } +// &[n-placement$="bottom-start"] { +// margin-top: 6px; +// } +// &[n-placement$="bottom"] { +// margin-top: 6px; +// } +// &[n-placement$="bottom-end"] { +// margin-top: 6px; +// } +// &[n-placement$="left-start"] { +// margin-right: 6px; +// }&[n-placement$="left"] { +// margin-right: 6px; +// } +// &[n-placement$="left-end"] { +// margin-right: 6px; +// } +// &[n-placement$="right-start"] { +// margin-left: 6px; +// } +// &[n-placement$="right"] { +// margin-left: 6px; +// } +// &[n-placement$="right-end"] { +// margin-left: 6px; +// } +// } +// &[n-placement$="top-start"] { +// margin-bottom: 10px; +// @include b(popover-arrow-wrapper) { +// right: 0; +// left: 0; +// top: 100%; +// height: $--n-popover-arrow-width * 2; +// @include b(popover-arrow) { +// top: -$--n-popover-arrow-width; +// left: 10px; +// } +// } +// } +// &[n-placement$="top"] { +// margin-bottom: 10px; +// @include b(popover-arrow-wrapper) { +// right: 0; +// left: 0; +// top: 100%; +// height: $--n-popover-arrow-width * 2; +// @include b(popover-arrow) { +// top: -$--n-popover-arrow-width; +// transform: translateX(-$--n-popover-arrow-width) rotate(45deg) ; +// left: 50%; +// } +// } +// } +// &[n-placement$="top-end"] { +// margin-bottom: 10px; +// @include b(popover-arrow-wrapper) { +// right: 0; +// left: 0; +// top: 100%; +// height: $--n-popover-arrow-width * 2; +// @include b(popover-arrow) { +// top: -$--n-popover-arrow-width; +// right: 10px; +// } +// } +// } +// &[n-placement$="bottom-start"] { +// margin-top: 10px; +// @include b(popover-arrow-wrapper) { +// right: 0; +// left: 0; +// bottom: 100%; +// height: $--n-popover-arrow-width * 2; +// @include b(popover-arrow) { +// bottom: -$--n-popover-arrow-width; +// left: 10px; +// } +// } +// } +// &[n-placement$="bottom"] { +// margin-top: 10px; +// @include b(popover-arrow-wrapper) { +// right: 0; +// left: 0; +// bottom: 100%; +// height: $--n-popover-arrow-width * 2; +// @include b(popover-arrow) { +// bottom: -$--n-popover-arrow-width; +// transform: translateX(-$--n-popover-arrow-width) rotate(45deg) ; +// left: 50%; +// } +// } +// } +// &[n-placement$="bottom-end"] { +// margin-top: 10px; +// @include b(popover-arrow-wrapper) { +// right: 0; +// left: 0; +// bottom: 100%; +// height: $--n-popover-arrow-width * 2; +// @include b(popover-arrow) { +// bottom: -$--n-popover-arrow-width; +// right: 10px; +// } +// } +// } +// &[n-placement$="left-start"] { +// margin-right: 10px; +// @include b(popover-arrow-wrapper) { +// top: 0; +// bottom: 0; +// left: 100%; +// width: $--n-popover-arrow-width * 2; +// @include b(popover-arrow) { +// left: -$--n-popover-arrow-width; +// top: 10px; +// } +// } +// } +// &[n-placement$="left"] { +// margin-right: 10px; +// @include b(popover-arrow-wrapper) { +// top: 0; +// bottom: 0; +// left: 100%; +// width: $--n-popover-arrow-width * 2; +// @include b(popover-arrow) { +// left: -$--n-popover-arrow-width; +// transform: translateY(-$--n-popover-arrow-width) rotate(45deg) ; +// top: 50%; +// } +// } +// } +// &[n-placement$="left-end"] { +// margin-right: 10px; +// @include b(popover-arrow-wrapper) { +// top: 0; +// bottom: 0; +// left: 100%; +// width: $--n-popover-arrow-width * 2; +// @include b(popover-arrow) { +// left: -$--n-popover-arrow-width; +// bottom: 10px; +// } +// } +// } +// &[n-placement$="right-start"] { +// margin-left: 10px; +// @include b(popover-arrow-wrapper) { +// top: 0; +// bottom: 0; +// right: 100%; +// width: $--n-popover-arrow-width * 2; +// @include b(popover-arrow) { +// right: -$--n-popover-arrow-width; +// top: 10px; +// } +// } +// } +// &[n-placement$="right"] { +// margin-left: 10px; +// @include b(popover-arrow-wrapper) { +// top: 0; +// bottom: 0; +// right: 100%; +// width: $--n-popover-arrow-width * 2; +// @include b(popover-arrow) { +// right: -$--n-popover-arrow-width; +// transform: translateY(-$--n-popover-arrow-width) rotate(45deg) ; +// top: 50%; +// } +// } +// } +// &[n-placement$="right-end"] { +// margin-left: 10px; +// @include b(popover-arrow-wrapper) { +// top: 0; +// bottom: 0; +// right: 100%; +// width: $--n-popover-arrow-width * 2; +// @include b(popover-arrow) { +// right: -$--n-popover-arrow-width; +// bottom: 10px; +// } +// } +// } +// } +// @include m(styled) { +// background-color: $--popover-background-color; +// } +// color: $--popover-text-color; +// @include b(popover-arrow-wrapper) { +// @include b(popover-arrow) { +// background-color: $--popover-background-color; +// } +// } +// @include m(shadow) { +// box-shadow: $--popover-box-shadow; +// } +// } +// } diff --git a/src/_styles/index.scss b/src/_styles/index.scss index 37abaafec..c3de3b6b8 100644 --- a/src/_styles/index.scss +++ b/src/_styles/index.scss @@ -5,6 +5,8 @@ @import './Descriptions.scss'; @import './Form.scss'; -@import './Popover.scss'; +// @import './Popover.scss'; +// @import './Tabs.scss'; +// @import './Table.scss'; @import './Tooltip.scss'; @import './Upload.scss'; \ No newline at end of file diff --git a/src/data-table/src/HeaderButton/FilterButton.vue b/src/data-table/src/HeaderButton/FilterButton.vue index d72911501..60d13a0bd 100644 --- a/src/data-table/src/HeaderButton/FilterButton.vue +++ b/src/data-table/src/HeaderButton/FilterButton.vue @@ -38,7 +38,7 @@