menu-item improvements
This commit is contained in:
parent
9ec61d0f0a
commit
98f972e557
16 changed files with 209 additions and 251 deletions
13
src/components/border.style.js
Normal file
13
src/components/border.style.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
export default {
|
||||
name: 'Border',
|
||||
selector: '/*border*/',
|
||||
virtual: true,
|
||||
defaultRules: [
|
||||
{
|
||||
directives: {
|
||||
textColor: '$mod(--parent, 10)',
|
||||
textAuto: 'no-auto'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -23,28 +23,37 @@ const hoverGlow = {
|
|||
export default {
|
||||
name: 'Button', // Name of the component
|
||||
selector: '.button', // CSS selector/prefix
|
||||
// States, system witll calculate ALL possible combinations of those and append a "normal" to them + standalone "normal" state
|
||||
// outOfTreeSelector: '' // out-of-tree selector is used when other components are laid over it but it's not part of the tree, see Underlay component
|
||||
// States, system witll calculate ALL possible combinations of those and prepend "normal" to them + standalone "normal" state
|
||||
states: {
|
||||
// normal: state is implicitly added
|
||||
// States are a bit expensive - the amount of combinations generated is about (1/6)n^3+n, so adding more state increased number of combination by an order of magnitude!
|
||||
// All states inherit from "normal" state, there is no other inheirtance, i.e. hover+disabled only inherits from "normal", not from hover nor disabled.
|
||||
// However, cascading still works, so resulting state will be result of merging of all relevant states/variants
|
||||
// normal: '' // normal state is implicitly added, it is always included
|
||||
disabled: ':disabled',
|
||||
toggled: '.toggled',
|
||||
pressed: ':active',
|
||||
hover: ':hover',
|
||||
focused: ':focus-within'
|
||||
},
|
||||
// Variants are mutually exclusive, which saves on computation time
|
||||
// Variants are mutually exclusive, each component implicitly has "normal" variant, and all other variants inherit from it.
|
||||
variants: {
|
||||
normal: '-default', // you can override normal variant
|
||||
danger: '.danger',
|
||||
unstyled: '-unstyled'
|
||||
// Variants save on computation time since adding new variant just adds one more "set".
|
||||
normal: '-default', // you can override normal variant, it will be appenended to the main class
|
||||
danger: '-default.danger'
|
||||
// Overall the compuation difficulty is N*((1/6)M^3+M) where M is number of distinct states and N is number of variants.
|
||||
// This (currently) is further multipled by number of places where component can exist.
|
||||
},
|
||||
// This lists all other components that can possibly exist within one. Recursion is currently not supported (and probably won't be supported ever).
|
||||
validInnerComponents: [
|
||||
'Text',
|
||||
'Icon'
|
||||
],
|
||||
// Default rules, used as "default theme", essentially.
|
||||
defaultRules: [
|
||||
{
|
||||
component: 'Button',
|
||||
// component: 'Button', // no need to specify components every time unless you're specifying how other component should look
|
||||
// like within it
|
||||
directives: {
|
||||
background: '--fg',
|
||||
shadow: [{
|
||||
|
|
@ -58,7 +67,6 @@ export default {
|
|||
}
|
||||
},
|
||||
{
|
||||
component: 'Button',
|
||||
variant: 'unstyled',
|
||||
directives: {
|
||||
background: '--fg',
|
||||
|
|
@ -66,14 +74,12 @@ export default {
|
|||
}
|
||||
},
|
||||
{
|
||||
component: 'Button',
|
||||
state: ['hover'],
|
||||
directives: {
|
||||
shadow: [hoverGlow, ...buttonInsetFakeBorders]
|
||||
}
|
||||
},
|
||||
{
|
||||
component: 'Button',
|
||||
state: ['hover', 'pressed'],
|
||||
directives: {
|
||||
background: '--accent,-24.2',
|
||||
|
|
@ -81,7 +87,6 @@ export default {
|
|||
}
|
||||
},
|
||||
{
|
||||
component: 'Button',
|
||||
state: ['disabled'],
|
||||
directives: {
|
||||
background: '$blend(--background, 0.25, --parent)',
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
export default {
|
||||
name: 'DropdownMenu',
|
||||
selector: '.dropdown',
|
||||
validInnerComponents: [
|
||||
'Text',
|
||||
'Icon',
|
||||
'Input'
|
||||
],
|
||||
states: {
|
||||
hover: ':hover'
|
||||
},
|
||||
defaultRules: [
|
||||
{
|
||||
directives: {
|
||||
background: '--fg'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
45
src/components/menu_item.style.js
Normal file
45
src/components/menu_item.style.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
export default {
|
||||
name: 'MenuItem',
|
||||
selector: '.menu-item',
|
||||
validInnerComponents: [
|
||||
'Text',
|
||||
'Icon',
|
||||
'Input',
|
||||
'Border'
|
||||
],
|
||||
states: {
|
||||
hover: ':hover',
|
||||
active: 'active'
|
||||
},
|
||||
defaultRules: [
|
||||
{
|
||||
directives: {
|
||||
background: '--fg'
|
||||
}
|
||||
},
|
||||
{
|
||||
component: 'Text',
|
||||
variant: 'normal',
|
||||
parent: {
|
||||
component: 'MenuItem',
|
||||
state: ['normal', 'hover'],
|
||||
variant: 'normal'
|
||||
},
|
||||
directives: {
|
||||
textColor: '--link',
|
||||
textAuto: 'no-preserve'
|
||||
}
|
||||
},
|
||||
{
|
||||
component: 'Icon',
|
||||
parent: {
|
||||
component: 'MenuItem',
|
||||
state: ['hover']
|
||||
},
|
||||
directives: {
|
||||
textColor: '--link',
|
||||
textAuto: 'no-preserve'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
8
src/components/modals.style.js
Normal file
8
src/components/modals.style.js
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
export default {
|
||||
name: 'Modals',
|
||||
selector: '.modal-view',
|
||||
validInnerComponents: [
|
||||
'Panel'
|
||||
],
|
||||
defaultRules: []
|
||||
}
|
||||
|
|
@ -107,7 +107,7 @@
|
|||
.NavPanel {
|
||||
.panel {
|
||||
overflow: hidden;
|
||||
box-shadow: var(--panelShadow);
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
ul {
|
||||
|
|
@ -124,14 +124,14 @@
|
|||
}
|
||||
|
||||
> li {
|
||||
&:first-child .menu-item {
|
||||
&:first-child.menu-item {
|
||||
border-top-right-radius: $fallback--panelRadius;
|
||||
border-top-right-radius: var(--panelRadius, $fallback--panelRadius);
|
||||
border-top-left-radius: $fallback--panelRadius;
|
||||
border-top-left-radius: var(--panelRadius, $fallback--panelRadius);
|
||||
}
|
||||
|
||||
&:last-child .menu-item {
|
||||
&:last-child.menu-item {
|
||||
border-bottom-right-radius: $fallback--panelRadius;
|
||||
border-bottom-right-radius: var(--panelRadius, $fallback--panelRadius);
|
||||
border-bottom-left-radius: $fallback--panelRadius;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<template>
|
||||
<OptionalRouterLink
|
||||
v-slot="{ isActive, href, navigate } = {}"
|
||||
ass="ass"
|
||||
:to="routeTo"
|
||||
>
|
||||
<li
|
||||
|
|
@ -96,40 +95,5 @@
|
|||
margin-right: -0.8em;
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: $fallback--lightBg;
|
||||
background-color: var(--selectedMenu, $fallback--lightBg);
|
||||
color: $fallback--link;
|
||||
color: var(--selectedMenuText, $fallback--link);
|
||||
|
||||
--faint: var(--selectedMenuFaintText, $fallback--faint);
|
||||
--faintLink: var(--selectedMenuFaintLink, $fallback--faint);
|
||||
--lightText: var(--selectedMenuLightText, $fallback--lightText);
|
||||
|
||||
.menu-icon {
|
||||
--icon: var(--text, $fallback--icon);
|
||||
}
|
||||
}
|
||||
|
||||
&.-active {
|
||||
font-weight: bolder;
|
||||
background-color: $fallback--lightBg;
|
||||
background-color: var(--selectedMenu, $fallback--lightBg);
|
||||
color: $fallback--text;
|
||||
color: var(--selectedMenuText, $fallback--text);
|
||||
|
||||
--faint: var(--selectedMenuFaintText, $fallback--faint);
|
||||
--faintLink: var(--selectedMenuFaintLink, $fallback--faint);
|
||||
--lightText: var(--selectedMenuLightText, $fallback--lightText);
|
||||
|
||||
.menu-icon {
|
||||
--icon: var(--text, $fallback--icon);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -7,12 +7,21 @@ export default {
|
|||
'Icon',
|
||||
'Button',
|
||||
'Input',
|
||||
'PanelHeader'
|
||||
'PanelHeader',
|
||||
'MenuItem'
|
||||
],
|
||||
defaultRules: [
|
||||
{
|
||||
directives: {
|
||||
background: '--bg'
|
||||
background: '--bg',
|
||||
shadow: [{
|
||||
x: 1,
|
||||
y: 1,
|
||||
blur: 4,
|
||||
spread: 0,
|
||||
color: '#000000',
|
||||
alpha: 0.6
|
||||
}]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ export default {
|
|||
{
|
||||
component: 'PanelHeader',
|
||||
directives: {
|
||||
background: '--fg'
|
||||
background: '--fg',
|
||||
shadow: []
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
export default {
|
||||
name: 'Popover',
|
||||
selector: '.popover',
|
||||
variants: {
|
||||
tooltip: '.tooltip',
|
||||
modal: '.modal'
|
||||
},
|
||||
validInnerComponents: [
|
||||
'Text',
|
||||
'Link',
|
||||
|
|
@ -8,12 +12,20 @@ export default {
|
|||
'Button',
|
||||
'Input',
|
||||
'PanelHeader',
|
||||
'DropdownMenu'
|
||||
'MenuItem'
|
||||
],
|
||||
defaultRules: [
|
||||
{
|
||||
directives: {
|
||||
background: '--fg'
|
||||
background: '--bg',
|
||||
shadow: [{
|
||||
x: 2,
|
||||
y: 2,
|
||||
blur: 3,
|
||||
spread: 0,
|
||||
color: '#000000',
|
||||
alpha: 0.5
|
||||
}]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ export default {
|
|||
selector: ':root',
|
||||
validInnerComponents: [
|
||||
'Underlay',
|
||||
'TopBar',
|
||||
'Popover'
|
||||
'Modals',
|
||||
'TopBar'
|
||||
],
|
||||
defaultRules: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
export default {
|
||||
name: 'Underlay',
|
||||
selector: 'body', // Should be '#content' but for now this is better for testing until I have proper popovers and such...
|
||||
selector: '#content',
|
||||
// Out of tree selector: Most components are laid over underlay, but underlay itself is not part of the DOM tree,
|
||||
// i.e. it's a separate absolutely-positioned component, so we need to treat it differently depending on whether
|
||||
// we are searching for underlay specifically or for whatever is laid on top of it.
|
||||
outOfTreeSelector: '.underlay',
|
||||
validInnerComponents: [
|
||||
'Panel'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue