From 740f43e2bac7b1eee919351694905fecf9291943 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Sun, 21 Aug 2022 16:56:11 +0200 Subject: feat: Before tailwind --- .../src/styles/components/responsive-sidebar.scss | 77 ++++--- .../src/styles/components/side-navigation-v4.scss | 237 +++++++++++++++++++++ .../src/styles/components/side-navigation.scss | 231 -------------------- .../src/styles/custom-style/_typography.scss | 10 +- apps/web-shared/src/styles/custom-style/_util.scss | 7 - 5 files changed, 291 insertions(+), 271 deletions(-) create mode 100644 apps/web-shared/src/styles/components/side-navigation-v4.scss delete mode 100644 apps/web-shared/src/styles/components/side-navigation.scss (limited to 'apps/web-shared/src/styles') diff --git a/apps/web-shared/src/styles/components/responsive-sidebar.scss b/apps/web-shared/src/styles/components/responsive-sidebar.scss index 29a45f4..71c86da 100644 --- a/apps/web-shared/src/styles/components/responsive-sidebar.scss +++ b/apps/web-shared/src/styles/components/responsive-sidebar.scss @@ -1,15 +1,16 @@ @use '../base' as *; /* -------------------------------- + File#: _1_responsive-sidebar Title: Responsive Sidebar Descr: Responsive sidebar container Usage: codyhouse.co/license --------------------------------- */ -$maxwidth: 250px; +-------------------------------- */ -.sidebar { +/* mobile version only (--default) 👇 */ +.sidebar:not(.sidebar--static) { position: fixed; top: 0; left: 0; @@ -17,6 +18,7 @@ $maxwidth: 250px; width: 100%; height: 100%; visibility: hidden; + transition: visibility 0s 0.3s; &::after { /* overlay layer */ content: ''; @@ -26,36 +28,23 @@ $maxwidth: 250px; width: 100%; height: 100%; background-color: alpha(var(--color-black), 0); + transition: background-color .3s; z-index: 1; } - @include breakpoint(sm) { - visibility: visible; - position: relative; - z-index: 1; - width: 100%; - max-width: $maxwidth; - border-right: var(--border-width, 1px) var(--border-style, solid) hsla(var(--color-contrast-lower-h), var(--color-contrast-lower-s), var(--color-contrast-lower-l), var(--border-o, 1)); - - .sidebar__header { - display: none; - } - - .sidebar__panel { - position: relative !important; - } - } - - .sidebar__panel { + .sidebar__panel { /* content */ position: absolute; top: 0; left: 0; z-index: 2; width: 100%; + max-width: 380px; height: 100%; overflow: auto; -webkit-overflow-scrolling: touch; background-color: var(--color-bg); + transform: translateX(-100%); + transition: box-shadow 0.3s,transform 0.3s; } &.sidebar--right-on-mobile { @@ -68,9 +57,10 @@ $maxwidth: 250px; &.sidebar--is-visible { visibility: visible; - + transition: none; + &::after { - background-color: alpha(var(--color-black), 0.55); + background-color: alpha(var(--color-black), 0.85); } .sidebar__panel { @@ -79,6 +69,7 @@ $maxwidth: 250px; } } } +/* end mobile version */ .sidebar__header { display: flex; @@ -96,8 +87,9 @@ $maxwidth: 250px; border-radius: 50%; background-color: var(--color-bg-light); box-shadow: var(--inner-glow), var(--shadow-sm); + transition: .2s; flex-shrink: 0; - + .icon { display: block; margin: auto; @@ -108,3 +100,40 @@ $maxwidth: 250px; box-shadow: var(--inner-glow), var(--shadow-md); } } + +/* desktop version only (--static) 👇 */ +.sidebar--static { + flex-shrink: 0; + flex-grow: 1; + + .sidebar__header { + display: none; + } +} + +.sidebar--sticky-on-desktop { + position: sticky; + top: var(--space-sm); + max-height: calc(100vh - var(--space-sm)); + overflow: auto; + -webkit-overflow-scrolling: touch; +} +/* end desktop version */ + +.sidebar--loaded { + opacity: 1; +} + + +.sidebar--static::before { + content: 'static'; +} + +@each $breakpoint, $value in $breakpoints { + .sidebar--static\@#{$breakpoint}::before { + content: 'mobile'; + @include breakpoint(#{$breakpoint}) { + content: 'static'; + } + } +} \ No newline at end of file diff --git a/apps/web-shared/src/styles/components/side-navigation-v4.scss b/apps/web-shared/src/styles/components/side-navigation-v4.scss new file mode 100644 index 0000000..c2c13d2 --- /dev/null +++ b/apps/web-shared/src/styles/components/side-navigation-v4.scss @@ -0,0 +1,237 @@ +@use '../base' as *; +@use 'responsive-sidebar.scss' as *; + +/* -------------------------------- + +File#: _2_side-navigation-v4 +Title: Side Navigation v4 +Descr: Main, side navigation +Usage: codyhouse.co/license + +-------------------------------- */ + +.sidenav-v4 { + --sidenav-v4-icon-size: 20px; + --sidenav-v4-icon-margin-right: var(--space-xxs); +} + +.sidenav-v4__item { + position: relative; +} + +.sidenav-v4__link, +.sidenav-v4__sub-link, +.sidenav-v4__separator { + padding: var(--space-sm); +} + +.sidenav-v4__link, .sidenav-v4__sub-link { + display: flex; + align-items: center; + + width: 100%; + border-radius: var(--radius-md); + + text-decoration: none; + color: inherit; + line-height: 1; + font-size: var(--text-md); + + transition: .2s; + + &:hover { + color: var(--color-primary); + background-color: alpha(var(--color-contrast-higher), 0.075); + } + + &[aria-current="page"] { + color: var(--color-primary); + } +} + +.sidenav-v4__sub-link { + position: relative; + color: var(--color-contrast-medium); + + /* dot indicator */ + &::before { + content: ''; + display: block; + --size: 6px; + width: var(--size); + height: var(--size); + background: currentColor; + border-radius: 50%; + margin-left: calc(var(--sidenav-v4-icon-size)/2 - var(--size)/2); + margin-right: calc(var(--sidenav-v4-icon-size)/2 - var(--size)/2 + var(--sidenav-v4-icon-margin-right)); + + opacity: 0; /* visible only if current */ + } + + &[aria-current="page"] { + &::before { /* show dot indicator */ + opacity: 1; + } + } +} + +.sidenav-v4__notification-marker { + margin-left: auto; + background-color: var(--color-accent); + border-radius: var(--radius-md); + + height: 16px; + line-height: 16px; + padding: 0 4px; + color: var(--color-white); + font-size: 12px; + + /* hide - visible only on desktop */ + display: none; +} + +/* label icon */ +.sidenav-v4__icon { + --size: var(--sidenav-v4-icon-size); + margin-right: var(--sidenav-v4-icon-margin-right); +} + +/* arrow icon - visible on mobile if item is expandable */ +.sidenav-v4__arrow-icon { + --size: 20px; + + .icon__group { + will-change: transform; + transform-origin: 50% 50%; + transform: rotate(-90deg); + transition: transform .3s var(--ease-out); + + > * { + transform-origin: 50% 50%; + stroke-dasharray: 20; + stroke-dashoffset: 0; + transform: translateY(0px); + transition: transform .3s, stroke-dashoffset .3s; + transition-timing-function: var(--ease-out); + } + + .sidenav-v4__item--collapsed & { + transform: rotate(0deg); + + > * { + transform: translateY(4px); + } + + > *:first-child { + stroke-dashoffset: 10.15; + } + + > *:last-child { + stroke-dashoffset: 10.15; + } + } + } + + /* hide icon for links - show only for buttons created in JS */ + .sidenav-v4__link--href & { + display: none; + } +} + +/* current item */ +.sidenav-v4__item--current { + .sidenav-v4__sub-list { + display: block; /* show sublist */ + } +} + +/* separator */ +.sidenav-v4__separator { + span { + display: block; + width: var(--sidenav-v4-icon-size); + height: 1px; + background-color: var(--color-contrast-lower); + } +} + +/* mobile only */ +@include breakpoint(md, "not all") { + .sidenav-v4__item--collapsed { + .sidenav-v4__sub-list { + display: none; + } + } + + .sidenav-v4__link--href { + display: none; /* hide link -> show button */ + } +} + +/* desktop */ +@include breakpoint(md) { + .sidenav-v4__sub-list { + display: none; + } + + .sidenav-v4__link, + .sidenav-v4__sub-link, + .sidenav-v4__separator { + padding: var(--space-xs); + } + + .sidenav-v4__link, + .sidenav-v4__sub-link { + font-size: var(--text-sm); + } + + .sidenav-v4__link--btn { + display: none; /* hide button -> show link */ + } + + /* tooltip */ + .sidenav-v4__item:not(.sidenav-v4__item--current) { + .sidenav-v4__sub-list { + width: 220px; + position: absolute; + z-index: var(--z-index-overlay); + left: 100%; + top: 0; + + background-color: var(--color-bg-light); + box-shadow: var(--inner-glow), var(--shadow-md); + border-radius: var(--radius-md); + + overflow: hidden; + } + + .sidenav-v4__sub-link { + border-radius: 0; + color: var(--color-contrast-high); + + &::before { + display: none; /* remove dot indicator */ + } + + &:hover { + color: var(--color-primary); + } + } + + &.sidenav-v4__item--hover, &:focus-within { + .sidenav-v4__sub-list { + display: block; + } + } + + &:hover .sidenav-v4__link { /* highlight main link if tooltip is visible */ + color: var(--color-primary); + background-color: alpha(var(--color-contrast-higher), 0.075); + } + } + + /* notification marker */ + .sidenav-v4__notification-marker { + display: block; + } +} \ No newline at end of file diff --git a/apps/web-shared/src/styles/components/side-navigation.scss b/apps/web-shared/src/styles/components/side-navigation.scss deleted file mode 100644 index 2e6597b..0000000 --- a/apps/web-shared/src/styles/components/side-navigation.scss +++ /dev/null @@ -1,231 +0,0 @@ -@use '../base' as *; -@use 'vanilla-responsive-sidebar' as *; - -/* -------------------------------- - -File#: _2_side-navigation-v4 -Title: Side Navigation v4 -Descr: Main, side navigation -Usage: codyhouse.co/license - --------------------------------- */ - -.sidenav-v4 { - --sidenav-v4-icon-size: 20px; - --sidenav-v4-icon-margin-right: var(--space-xxs); -} - -.sidenav-v4__item { - position: relative; -} - -.sidenav-v4__link, -.sidenav-v4__sub-link, -.sidenav-v4__separator { - padding: var(--space-sm); -} - -.sidenav-v4__link, .sidenav-v4__sub-link { - display: flex; - align-items: center; - - width: 100%; - border-radius: var(--radius-md); - - text-decoration: none; - color: inherit; - line-height: 1; - font-size: var(--text-md); - - transition: .2s; - - &:hover { - color: var(--color-primary); - background-color: alpha(var(--color-contrast-higher), 0.075); - } - - &[aria-current="page"] { - color: var(--color-primary); - } -} - -.sidenav-v4__sub-link { - position: relative; - color: var(--color-contrast-medium); - - /* dot indicator */ - &::before { - content: ''; - display: block; - --size: 6px; - width: var(--size); - height: var(--size); - background: currentColor; - border-radius: 50%; - margin-left: calc(var(--sidenav-v4-icon-size)/2 - var(--size)/2); - margin-right: calc(var(--sidenav-v4-icon-size)/2 - var(--size)/2 + var(--sidenav-v4-icon-margin-right)); - - opacity: 0; /* visible only if current */ - } - - &[aria-current="page"] { - &::before { /* show dot indicator */ - opacity: 1; - } - } -} - -.sidenav-v4__notification-marker { - margin-left: auto; - background-color: var(--color-accent); - border-radius: var(--radius-md); - - height: 16px; - line-height: 16px; - padding: 0 4px; - color: var(--color-white); - font-size: 12px; - - /* hide - visible only on desktop */ - display: none; -} - -/* label icon */ -.sidenav-v4__icon { - --size: var(--sidenav-v4-icon-size); - margin-right: var(--sidenav-v4-icon-margin-right); -} - -/* arrow icon - visible on mobile if item is expandable */ -.sidenav-v4__arrow-icon { - --size: 20px; - - .icon__group { - will-change: transform; - transform-origin: 50% 50%; - transform: rotate(-90deg); - - > * { - transform-origin: 50% 50%; - stroke-dasharray: 20; - stroke-dashoffset: 0; - transform: translateY(0px); - transition-timing-function: var(--ease-out); - } - - .sidenav-v4__item--collapsed & { - transform: rotate(0deg); - - > * { - transform: translateY(4px); - } - - > *:first-child { - stroke-dashoffset: 10.15; - } - - > *:last-child { - stroke-dashoffset: 10.15; - } - } - } - -} - -/* current item */ -.sidenav-v4__item--current { - .sidenav-v4__sub-list { - display: block; /* show sublist */ - } -} - -/* separator */ -.sidenav-v4__separator { - span { - display: block; - width: var(--sidenav-v4-icon-size); - height: 1px; - background-color: var(--color-contrast-lower); - } -} - -/* mobile only */ -@include breakpoint(md, "not all") { - .sidenav-v4__item--collapsed { - .sidenav-v4__sub-list { - display: none; - } - } - - .sidenav-v4__link--href { - display: none; /* hide link -> show button */ - } -} - -/* desktop */ -@include breakpoint(md) { - .sidenav-v4__sub-list { - display: none; - } - - .sidenav-v4__link, - .sidenav-v4__sub-link, - .sidenav-v4__separator { - padding: var(--space-xs); - } - - .sidenav-v4__link, - .sidenav-v4__sub-link { - font-size: var(--text-base); - } - - .sidenav-v4__link--btn { - display: none; /* hide button -> show link */ - } - - /* tooltip */ - .sidenav-v4__item:not(.sidenav-v4__item--current) { - .sidenav-v4__sub-list { - width: 220px; - position: absolute; - z-index: var(--z-index-overlay); - left: 100%; - top: 0; - - background-color: var(--color-bg-light); - box-shadow: var(--inner-glow), var(--shadow-md); - border-radius: var(--radius-md); - - overflow: hidden; - } - - .sidenav-v4__sub-link { - border-radius: 0; - color: var(--color-contrast-high); - - &::before { - display: none; /* remove dot indicator */ - } - - &:hover { - color: var(--color-primary); - } - } - - &.sidenav-v4__item--hover, &:focus-within { - .sidenav-v4__sub-list { - display: block; - } - } - - &:hover .sidenav-v4__link { /* highlight main link if tooltip is visible */ - color: var(--color-primary); - background-color: alpha(var(--color-contrast-higher), 0.075); - } - } - - /* notification marker */ - .sidenav-v4__notification-marker { - display: block; - } -} diff --git a/apps/web-shared/src/styles/custom-style/_typography.scss b/apps/web-shared/src/styles/custom-style/_typography.scss index 3bf56a6..7fa98c5 100644 --- a/apps/web-shared/src/styles/custom-style/_typography.scss +++ b/apps/web-shared/src/styles/custom-style/_typography.scss @@ -15,7 +15,7 @@ --text-scale-ratio: 1.2; // multiplier used to generate the type scale values 👇 // line-height - --body-line-height: 1.4; + --body-line-height: 1; --heading-line-height: 1; // capital letters - used in combo with the lhCrop mixin @@ -37,14 +37,6 @@ --text-xxxxl: calc(var(--text-xxxl) * var(--text-scale-ratio)); } - -@include breakpoint(md) { - :root { - --text-base-size: 1.25rem; - --text-scale-ratio: 1.25; - } -} - body { font-family: var(--font-primary); } diff --git a/apps/web-shared/src/styles/custom-style/_util.scss b/apps/web-shared/src/styles/custom-style/_util.scss index 5d976a4..4b86e73 100644 --- a/apps/web-shared/src/styles/custom-style/_util.scss +++ b/apps/web-shared/src/styles/custom-style/_util.scss @@ -1,15 +1,8 @@ @use '../base' as *; -// -------------------------------- - -// How to create custom utility classes 👇 - -// -------------------------------- - .border-none { border: none !important; } -// } // 👇 (optional) create responsive variations - edit only [my-util-class, property, value] // @each $breakpoint, $value in $breakpoints { -- cgit v1.3