cirrus-ui
Version:
A lightweight UI framework written in SCSS
384 lines (327 loc) • 10.8 kB
Plain Text
@use '../src/internal' as *;
@if should-generate-classes($LISTS) {
/* LISTS */
ul,
ol {
margin: 1rem 0 1rem 1rem;
padding-inline-start: 0.5rem;
/* Handle nesting */
& ul,
& ol {
margin: 0 0 0 1rem;
}
}
ul {
list-style: disc;
/* Nested list bullet types */
& ul {
list-style-type: circle;
& ul {
list-style-type: square;
}
}
}
ol ol {
list-style: lower-alpha;
}
ol ol ol {
list-style: upper-roman;
}
/* Description lists */
dl {
margin: 1rem 0;
}
/* Detail title */
dt {
font-weight: 700;
}
dd {
margin-bottom: 0.5rem;
}
li {
margin: 0.25rem 0;
}
/* MISC */
ul {
&.no-bullets {
list-style: none;
}
/* MENU LISTS */
&.menu {
font-size: 1rem;
list-style: none;
margin: 0.5rem 0;
}
/* Style headers to have even space distribution. */
.menu-title:not(:first-child) {
margin-bottom: 1rem;
}
.menu-title:not(:last-child) {
margin-top: 1rem;
}
/* Style menu items */
$menu-item-allowed-children: 'a:first-child', 'div:first-child', 'span:first-child';
.menu-item > a:first-child,
.menu-item > div:first-child,
.menu-item > span:first-child {
color: fill('gray', '700');
display: block;
padding: 0.5em 0.75em;
border-radius: 3px;
font-size: var(--font-size-s);
transition: all var(--animation-duration);
}
.menu-item:hover > a:first-child,
.menu-item:hover > div:first-child,
.menu-item:hover > span:first-child {
background-color: rgba(208, 208, 208, 0.3);
color: fill('primary');
transition: all var(--animation-duration);
}
.menu-item.selected > a:first-child,
.menu-item.selected > div:first-child,
.menu-item.selected > span:first-child {
color: #fff;
background-color: fill('primary');
}
.menu-item .menu-addon {
z-index: 1;
position: relative;
color: var(--cirrus-fg);
cursor: pointer;
transition: all var(--animation-duration);
}
.menu-item .menu-addon .icon {
font-size: inherit;
vertical-align: auto;
}
.menu-item .menu-addon:hover {
transition: all var(--animation-duration);
}
.menu-item.selected .menu-addon {
color: #fff;
}
/* Style sub menus inside a menu */
.menu-item ul {
border-left: 1px solid fill('gray', '300');
margin: 0.75rem;
padding-left: 0.75rem;
}
/* Menu item divider */
.divider {
border-top: 0.1rem solid fill('gray', '200');
height: 0.1rem;
margin: 1rem 0;
}
/* Title for the section separated by the divider */
.divider::after {
content: attr(data-label); /* Text that will be displayed */
background-color: var(--cirrus-bg);
color: fill('gray', '500');
display: inline-block;
padding: 0 0.7rem;
margin: 0.5rem;
font-size: 0.7rem;
transform: translateY(-1.1rem);
}
}
/* Dropdown menu for dropdown buttons */
.list-dropdown {
display: inline-block;
position: relative;
.menu {
position: absolute;
top: 75%;
left: 0;
animation: slide-down var(--animation-duration) ease 1;
animation-play-state: paused;
background-color: var(--cirrus-bg);
border-radius: 0.2rem;
box-shadow: 0 1rem 3rem rgba(149, 157, 165, 0.3);
margin: 0;
opacity: 0;
min-width: 15rem;
padding: 0.25rem 0.5rem;
transform: translateY(0.5rem);
z-index: 10;
pointer-events: none; /* Remove pointer events to prevent mouse hover to show menu even though it is not visible */
overflow: hidden;
transition: all var(--animation-duration);
text-align: left;
@include screen-below($sm) {
height: 0;
padding: 0 ;
position: relative;
}
}
&.dropdown-right .menu {
left: auto;
right: 0;
}
/* Allow for shown and :focus selectors for JS and native CSS transitions */
&.shown .menu,
.btn-dropdown:focus + .menu,
.menu:hover {
animation-play-state: running; /* Resume animation on focus */
display: block;
opacity: 1;
top: 100%;
z-index: 100;
pointer-events: auto; /* Restore pointer events */
height: auto;
}
.btn-group .btn-dropdown:nth-last-child(2) {
border-bottom-right-radius: 3px;
border-top-right-radius: 3px;
}
}
/* TREE */
/* Tree Navigation Menu */
.tree {
margin: 0;
.tree-item {
/* The title of the tree menu */
.tree-item-header {
display: block;
padding: 0.25rem 0.5rem;
cursor: pointer;
font-weight: 700; /* Keep styling consistent with menu-items */
}
/* The dropdown glyph of the tree menu */
.tree-item-header .icon {
transition: all var(--animation-duration);
}
/* Expand the tree-item-body (has menu-items) */
input:checked ~ .tree-item-body {
max-height: 100vh;
}
/* Rotate the dropdown glyph */
input:checked ~ .tree-item-header .icon {
transform: rotate(90deg);
}
/* Container for the menu-items of the tree menu */
.tree-item-body {
max-height: 0; /* Hidden at first */
margin-left: 1.5rem;
overflow: hidden;
transition: all var(--animation-duration);
}
}
}
/* The body that will encompass the tree-nav and tree-nav-content */
.tree-nav-body {
display: flex;
height: 100vh;
flex-wrap: nowrap;
/* A fixed menu on the side with a tree component */
.tree-nav {
flex-grow: 0;
flex-shrink: 1;
padding: 2rem 1rem 2rem 2rem;
min-width: 15rem;
height: 100vh;
overflow: auto;
}
/* The container for the tree component to prevent it from overflowing */
.tree-nav-container {
overflow-y: auto;
top: 4rem;
bottom: 1rem;
}
/* Darkened area that will close the navbar when clicked for mobile only */
.tree-nav-close {
display: none; /* Not needed in desktop */
}
/* Push document body further right to account for sidebar space */
& + .tree-nav-content {
max-width: 100%;
padding: 2rem;
flex: 1 0 auto;
overflow: auto;
margin: 0;
}
/* The body where all other HTML components are entered if a tree-nav is used */
.tree-nav-content {
width: 100%;
overflow: auto;
margin: 0;
padding: 2rem;
}
}
@include screen-below($sm) {
/* Hide the menu to the side by default */
.tree-nav-body .tree-nav {
height: 100%;
left: 0;
overflow-y: auto;
padding: 3rem 1.5rem;
position: fixed;
top: 0;
transform: translateX(-100%);
transition: transform var(--animation-duration) ease;
z-index: 400;
/* Open the menu from the side */
/* Use a link and add the id of this element as the url */
&.tree-nav--visible,
&:target {
transform: translateX(0);
transition: transform var(--animation-duration) ease;
/* Show the darkened area when the tree nav menu is clicked */
& + .tree-nav-close {
display: block;
background-color: rgba(0, 0, 0, 0.15);
height: 100%;
left: 0;
position: fixed;
right: 0;
top: 0;
width: 100%;
z-index: 300;
}
}
/* Create the area to click to close the menu */
.tree-nav-close {
background-color: rgba(0, 0, 0, 0.15);
display: none;
height: 100%;
left: 0;
position: fixed;
right: 0;
top: 0;
width: 100%;
z-index: 300;
}
/* Reset max-width in mobile */
& + .tree-nav-body {
max-width: inherit;
}
}
/* Header bar for mobile websites with the tree-nav */
.tree-nav-header {
position: fixed;
top: 0;
left: 0;
right: 0;
background-color: rgba(248, 249, 250, 0.8);
height: 3.5rem;
padding: 0.75rem 0.5rem;
text-align: center;
z-index: 300;
}
/* For dropdown menu used in header (different from header dropdown) */
.nav-item.has-sub .list-dropdown {
width: 100%;
.btn-group {
width: 100%;
.btn-dropdown {
flex-grow: 0;
}
}
}
/* Show the dropdown menu in mobile hamburger menu relative with the header menu */
.list-dropdown .btn-dropdown:focus + .menu {
position: relative;
width: 100%;
}
}
}