From 98f972e557047a626880692189fdae68269a732e Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 11 Feb 2024 23:11:28 +0200 Subject: [PATCH] menu-item improvements --- src/App.scss | 84 +------------ src/components/border.style.js | 13 ++ src/components/button.style.js | 27 ++-- src/components/dropdown_menu.style.js | 19 --- src/components/menu_item.style.js | 45 +++++++ src/components/modals.style.js | 8 ++ src/components/nav_panel/nav_panel.vue | 6 +- .../navigation/navigation_entry.vue | 36 ------ src/components/panel.style.js | 13 +- src/components/panel_header.style.js | 3 +- src/components/popover.style.js | 16 ++- src/components/root.style.js | 4 +- src/components/underlay.style.js | 5 +- src/panel.scss | 49 +------- .../theme_data/theme_data_3.service.js | 118 ++++++++++-------- top_bar.style.js | 14 +++ 16 files changed, 209 insertions(+), 251 deletions(-) create mode 100644 src/components/border.style.js delete mode 100644 src/components/dropdown_menu.style.js create mode 100644 src/components/menu_item.style.js create mode 100644 src/components/modals.style.js diff --git a/src/App.scss b/src/App.scss index a8eecaf547..1f9bab407b 100644 --- a/src/App.scss +++ b/src/App.scss @@ -129,15 +129,6 @@ i[class*="icon-"], color: var(--icon); } -.button-unstyled:hover, -a:hover { - > i[class*="icon-"], - > .svg-inline--fa, - > .iconLetter { - color: var(--text); - } -} - nav { z-index: var(--ZI_navbar); background-color: $fallback--fg; @@ -192,8 +183,7 @@ nav { grid-column: 1 / span 3; grid-row: 1 / 1; pointer-events: none; - background-color: rgb(0 0 0 / 15%); - background-color: var(--underlay, rgb(0 0 0 / 15%)); + background-color: var(--underlay); z-index: -1000; } @@ -363,10 +353,7 @@ nav { .button-default { user-select: none; - color: $fallback--text; - color: var(--btnText, $fallback--text); - background-color: $fallback--fg; - background-color: var(--btn, $fallback--fg); + color: var(--text); border: none; border-radius: $fallback--btnRadius; border-radius: var(--btnRadius, $fallback--btnRadius); @@ -376,70 +363,12 @@ nav { font-family: sans-serif; font-family: var(--interfaceFont, sans-serif); - &.-sublime { - background: transparent; - } - - i[class*="icon-"], - .svg-inline--fa { - color: var(--icon); - } - &::-moz-focus-inner { border: none; } - &:active { - color: $fallback--text; - color: var(--btnPressedText, $fallback--text); - background-color: $fallback--fg; - background-color: var(--btnPressed, $fallback--fg); - - svg, - i { - color: $fallback--text; - color: var(--btnPressedText, $fallback--text); - } - } - &:disabled { cursor: not-allowed; - color: $fallback--text; - color: var(--btnDisabledText, $fallback--text); - background-color: $fallback--fg; - background-color: var(--btnDisabled, $fallback--fg); - - svg, - i { - color: $fallback--text; - color: var(--btnDisabledText, $fallback--text); - } - } - - &.toggled { - color: $fallback--text; - color: var(--btnToggledText, $fallback--text); - background-color: $fallback--fg; - background-color: var(--btnToggled, $fallback--fg); - box-shadow: - 0 0 4px 0 rgb(255 255 255 / 30%), - 0 1px 0 0 rgb(0 0 0 / 20%) inset, - 0 -1px 0 0 rgb(255 255 255 / 20%) inset; - box-shadow: var(--buttonPressedShadow); - - svg, - i { - color: $fallback--text; - color: var(--btnToggledText, $fallback--text); - } - } - - &.danger { - // TODO: add better color variable - color: $fallback--text; - color: var(--alertErrorPanelText, $fallback--text); - background-color: $fallback--alertError; - background-color: var(--alertError, $fallback--alertError); } } @@ -458,8 +387,7 @@ nav { color: inherit; &.-link { - color: $fallback--link; - color: var(--link, $fallback--link); + color: var(--link); } &.-fullwidth { @@ -510,7 +438,6 @@ textarea { &[disabled="disabled"], &.disabled { cursor: not-allowed; - opacity: 0.5; } &[type="range"] { @@ -610,9 +537,7 @@ textarea { } option { - color: $fallback--text; - color: var(--text, $fallback--text); - background-color: $fallback--bg; + color: var(--text); background-color: var(--bg, $fallback--bg); } @@ -746,6 +671,7 @@ option { .faint { --text: var(--textFaint); --textGreentext: var(--textGreentextFaint); + --textCyantext: var(--textCyantextFaint); --link: var(--linkFaint); color: var(--text); diff --git a/src/components/border.style.js b/src/components/border.style.js new file mode 100644 index 0000000000..a87ee9c87e --- /dev/null +++ b/src/components/border.style.js @@ -0,0 +1,13 @@ +export default { + name: 'Border', + selector: '/*border*/', + virtual: true, + defaultRules: [ + { + directives: { + textColor: '$mod(--parent, 10)', + textAuto: 'no-auto' + } + } + ] +} diff --git a/src/components/button.style.js b/src/components/button.style.js index c86fee64c8..84db88fbe6 100644 --- a/src/components/button.style.js +++ b/src/components/button.style.js @@ -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)', diff --git a/src/components/dropdown_menu.style.js b/src/components/dropdown_menu.style.js deleted file mode 100644 index 905984e924..0000000000 --- a/src/components/dropdown_menu.style.js +++ /dev/null @@ -1,19 +0,0 @@ -export default { - name: 'DropdownMenu', - selector: '.dropdown', - validInnerComponents: [ - 'Text', - 'Icon', - 'Input' - ], - states: { - hover: ':hover' - }, - defaultRules: [ - { - directives: { - background: '--fg' - } - } - ] -} diff --git a/src/components/menu_item.style.js b/src/components/menu_item.style.js new file mode 100644 index 0000000000..43b5c35a3a --- /dev/null +++ b/src/components/menu_item.style.js @@ -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' + } + } + ] +} diff --git a/src/components/modals.style.js b/src/components/modals.style.js new file mode 100644 index 0000000000..3cfddf2fa8 --- /dev/null +++ b/src/components/modals.style.js @@ -0,0 +1,8 @@ +export default { + name: 'Modals', + selector: '.modal-view', + validInnerComponents: [ + 'Panel' + ], + defaultRules: [] +} diff --git a/src/components/nav_panel/nav_panel.vue b/src/components/nav_panel/nav_panel.vue index 1a826cc433..33547a4121 100644 --- a/src/components/nav_panel/nav_panel.vue +++ b/src/components/nav_panel/nav_panel.vue @@ -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; diff --git a/src/components/navigation/navigation_entry.vue b/src/components/navigation/navigation_entry.vue index 411ca53661..59722f6c1c 100644 --- a/src/components/navigation/navigation_entry.vue +++ b/src/components/navigation/navigation_entry.vue @@ -1,7 +1,6 @@