tabs support + cleanup

This commit is contained in:
Henry Jameson 2024-02-22 00:02:24 +02:00
parent 8a21594dbc
commit 879f520b75
9 changed files with 74 additions and 14 deletions

View File

@ -359,7 +359,6 @@ const afterStoreSetup = async ({ store, i18n }) => {
const { theme } = store.state.instance const { theme } = store.state.instance
const customThemePresent = customThemeSource || customTheme const customThemePresent = customThemeSource || customTheme
console.log({ ...customThemeSource }, { ...customTheme })
if (customThemePresent) { if (customThemePresent) {
if (customThemeSource && customThemeSource.themeEngineVersion === CURRENT_VERSION) { if (customThemeSource && customThemeSource.themeEngineVersion === CURRENT_VERSION) {
applyTheme(customThemeSource) applyTheme(customThemeSource)

View File

@ -5,7 +5,8 @@ export default {
'Text', 'Text',
'Icon', 'Icon',
'Link', 'Link',
'Border' 'Border',
'ButtonUnstyled'
], ],
variants: { variants: {
normal: '.neutral', normal: '.neutral',

View File

@ -3,8 +3,6 @@ export default {
selector: '.button-unstyled', selector: '.button-unstyled',
states: { states: {
disabled: ':disabled', disabled: ':disabled',
toggled: '.toggled',
pressed: ':active',
hover: ':hover:not(:disabled)', hover: ':hover:not(:disabled)',
focused: ':focus-within' focused: ':focus-within'
}, },

View File

@ -16,7 +16,8 @@ export default {
'Alert', 'Alert',
'UserCard', 'UserCard',
'Chat', 'Chat',
'Attachment' 'Attachment',
'Tab'
], ],
defaultRules: [ defaultRules: [
{ {

View File

@ -0,0 +1,52 @@
export default {
name: 'Tab', // Name of the component
selector: '.tab', // CSS selector/prefix
states: {
active: '.active',
hover: ':hover:not(:disabled)',
disabled: '.disabled'
},
validInnerComponents: [
'Text',
'Icon'
],
defaultRules: [
{
directives: {
background: '--fg',
shadow: ['--defaultButtonShadow', '--defaultButtonBevel'],
roundness: 3
}
},
{
state: ['hover'],
directives: {
shadow: ['--defaultButtonHoverGlow', '--defaultButtonBevel']
}
},
{
state: ['disabled'],
directives: {
background: '$blend(--inheritedBackground, 0.25, --parent)',
shadow: ['--defaultButtonBevel']
}
},
{
state: ['active'],
directives: {
opacity: 0
}
},
{
component: 'Text',
parent: {
component: 'Tab',
state: ['disabled']
},
directives: {
textOpacity: 0.25,
textOpacityMode: 'blend'
}
}
]
}

View File

@ -97,7 +97,7 @@ export default {
.map((slot, index) => { .map((slot, index) => {
const props = slot.props const props = slot.props
if (!props) return if (!props) return
const classesTab = ['tab', 'button-default'] const classesTab = ['tab']
const classesWrapper = ['tab-wrapper'] const classesWrapper = ['tab-wrapper']
if (this.activeIndex === index) { if (this.activeIndex === index) {
classesTab.push('active') classesTab.push('active')

View File

@ -25,8 +25,7 @@
content: ""; content: "";
flex: 1 1 auto; flex: 1 1 auto;
border-bottom: 1px solid; border-bottom: 1px solid;
border-bottom-color: $fallback--border; border-bottom-color: var(--border);
border-bottom-color: var(--border, $fallback--border);
} }
.tab-wrapper { .tab-wrapper {
@ -37,8 +36,7 @@
right: 0; right: 0;
bottom: 0; bottom: 0;
border-bottom: 1px solid; border-bottom: 1px solid;
border-bottom-color: $fallback--border; border-bottom-color: var(--border);
border-bottom-color: var(--border, $fallback--border);
} }
} }
@ -173,6 +171,14 @@
} }
.tab { .tab {
user-select: none;
color: var(--text);
border: none;
cursor: pointer;
box-shadow: var(--shadow);
font-size: 1em;
font-family: var(--interfaceFont, sans-serif);
border-radius: var(--roundness);
position: relative; position: relative;
white-space: nowrap; white-space: nowrap;
padding: 6px 1em; padding: 6px 1em;

View File

@ -9,7 +9,6 @@ export const parseCssShadow = (text) => {
const [x, y, blur = 0, spread = 0] = dimensions.split(/ /).filter(x => x).map(x => x.trim()) const [x, y, blur = 0, spread = 0] = dimensions.split(/ /).filter(x => x).map(x => x.trim())
const isInset = inset?.trim() === 'inset' const isInset = inset?.trim() === 'inset'
console.log(color.trim())
const colorString = color.split(/ /).filter(x => x).map(x => x.trim())[0] const colorString = color.split(/ /).filter(x => x).map(x => x.trim())[0]
return { return {

View File

@ -55,7 +55,7 @@ export const extendedBasePrefixes = [
'panel', 'panel',
'topBar', 'topBar',
// 'tab', // TODO: not implemented yet 'tab',
'btn', 'btn',
'input', 'input',
'selectedMenu', 'selectedMenu',
@ -122,6 +122,9 @@ export const convertTheme2To3 = (data) => {
case 'btn': case 'btn':
rule.component = 'Button' rule.component = 'Button'
break break
case 'tab':
rule.component = 'Tab'
break
case 'input': case 'input':
rule.component = 'Input' rule.component = 'Input'
break break
@ -155,6 +158,7 @@ export const convertTheme2To3 = (data) => {
newRules.push(rule) newRules.push(rule)
if (rule.component === 'Button') { if (rule.component === 'Button') {
newRules.push({ ...rule, component: 'ScrollbarElement' }) newRules.push({ ...rule, component: 'ScrollbarElement' })
newRules.push({ ...rule, component: 'Tab' })
} }
}) })
return newRules return newRules
@ -215,6 +219,7 @@ export const convertTheme2To3 = (data) => {
if (rule.component === 'Button') { if (rule.component === 'Button') {
newRules.push({ ...rule, component: 'ScrollbarElement' }) newRules.push({ ...rule, component: 'ScrollbarElement' })
newRules.push({ ...rule, component: 'Tab' })
} }
}) })
return newRules return newRules
@ -351,8 +356,7 @@ export const convertTheme2To3 = (data) => {
} }
if (newRule.component === 'Button') { if (newRule.component === 'Button') {
console.log([newRule, { ...newRule, component: 'ScrollbarElement' }]) return [newRule, { ...newRule, component: 'Tab' }, { ...newRule, component: 'ScrollbarElement' }]
return [newRule, { ...newRule, component: 'ScrollbarElement' }]
} else { } else {
return [newRule] return [newRule]
} }