From 53a4b1f9a6a9aa6bc044609c3accb074d924daf9 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 31 Jan 2024 17:39:51 +0200 Subject: better virtual components and stuff --- src/components/notification/notification.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/components/notification') diff --git a/src/components/notification/notification.vue b/src/components/notification/notification.vue index a8eceab0..5c425200 100644 --- a/src/components/notification/notification.vue +++ b/src/components/notification/notification.vue @@ -155,7 +155,7 @@ Date: Mon, 12 Feb 2024 19:17:17 +0200 Subject: separate greentext into "fun text" and make Post/Notification related components --- src/App.scss | 2 -- src/components/fun_text.style.js | 40 ++++++++++++++++++++++++ src/components/notification.style.js | 21 +++++++++++++ src/components/notification/notification.scss | 3 +- src/components/panel.style.js | 4 ++- src/components/popover.style.js | 3 +- src/components/post.style.js | 21 +++++++++++++ src/components/rich_content.style.js | 17 ++++++++++ src/components/rich_content/rich_content.scss | 8 +++++ src/components/status_body/status_body.scss | 8 ----- src/components/status_content/status_content.vue | 10 ++++++ src/components/text.style.js | 13 -------- src/services/theme_data/theme_data_3.service.js | 13 ++++++-- 13 files changed, 134 insertions(+), 29 deletions(-) create mode 100644 src/components/fun_text.style.js create mode 100644 src/components/notification.style.js create mode 100644 src/components/post.style.js create mode 100644 src/components/rich_content.style.js (limited to 'src/components/notification') diff --git a/src/App.scss b/src/App.scss index 27fee4b4..6a634926 100644 --- a/src/App.scss +++ b/src/App.scss @@ -673,8 +673,6 @@ option { .faint { --text: var(--textFaint); - --textGreentext: var(--textGreentextFaint); - --textCyantext: var(--textCyantextFaint); --link: var(--linkFaint); color: var(--text); diff --git a/src/components/fun_text.style.js b/src/components/fun_text.style.js new file mode 100644 index 00000000..2d3ac154 --- /dev/null +++ b/src/components/fun_text.style.js @@ -0,0 +1,40 @@ +export default { + name: 'FunText', + selector: '/*fun-text*/', + virtual: true, + variants: { + greentext: '.greentext', + cyantext: '.cyantext' + }, + states: { + faint: '.faint' + }, + defaultRules: [ + { + directives: { + textColor: '--text', + textAuto: 'preserve' + } + }, + { + state: ['faint'], + directives: { + textOpacity: 0.5 + } + }, + { + variant: 'greentext', + directives: { + textColor: '--cGreen', + textAuto: 'preserve' + } + }, + { + variant: 'cyantext', + directives: { + textColor: '--cBlue', + textAuto: 'preserve' + } + } + ] +} diff --git a/src/components/notification.style.js b/src/components/notification.style.js new file mode 100644 index 00000000..057b1c7a --- /dev/null +++ b/src/components/notification.style.js @@ -0,0 +1,21 @@ +export default { + name: 'Notification', + selector: '.Notification', + validInnerComponents: [ + 'Text', + 'Link', + 'Icon', + 'Border', + 'Button', + 'ButtonUnstyled', + 'RichContent', + 'Input' + ], + defaultRules: [ + { + directives: { + background: '--bg' + } + } + ] +} diff --git a/src/components/notification/notification.scss b/src/components/notification/notification.scss index 654aca3c..86d3e31d 100644 --- a/src/components/notification/notification.scss +++ b/src/components/notification/notification.scss @@ -3,8 +3,7 @@ // TODO Copypaste from Status, should unify it somehow .Notification { border-bottom: 1px solid; - border-color: $fallback--border; - border-color: var(--border, $fallback--border); + border-color: var(--border); word-wrap: break-word; word-break: break-word; diff --git a/src/components/panel.style.js b/src/components/panel.style.js index ce9812a6..1e8039c6 100644 --- a/src/components/panel.style.js +++ b/src/components/panel.style.js @@ -9,7 +9,9 @@ export default { 'ButtonUnstyled', 'Input', 'PanelHeader', - 'MenuItem' + 'MenuItem', + 'Post', + 'Notification' ], defaultRules: [ { diff --git a/src/components/popover.style.js b/src/components/popover.style.js index a3a554fd..6a121cae 100644 --- a/src/components/popover.style.js +++ b/src/components/popover.style.js @@ -13,7 +13,8 @@ export default { 'ButtonUnstyled', 'Input', 'PanelHeader', - 'MenuItem' + 'MenuItem', + 'Post' ], defaultRules: [ { diff --git a/src/components/post.style.js b/src/components/post.style.js new file mode 100644 index 00000000..92ec230a --- /dev/null +++ b/src/components/post.style.js @@ -0,0 +1,21 @@ +export default { + name: 'Post', + selector: '.Status', + validInnerComponents: [ + 'Text', + 'Link', + 'Icon', + 'Border', + 'Button', + 'ButtonUnstyled', + 'RichContent', + 'Input' + ], + defaultRules: [ + { + directives: { + background: '--bg' + } + } + ] +} diff --git a/src/components/rich_content.style.js b/src/components/rich_content.style.js new file mode 100644 index 00000000..aaf126a5 --- /dev/null +++ b/src/components/rich_content.style.js @@ -0,0 +1,17 @@ +export default { + name: 'RichContent', + selector: '.RichContent', + validInnerComponents: [ + 'Text', + 'FunText', + 'Link' + ], + defaultRules: [ + { + directives: { + background: '--bg', + textNoCssColor: 'yes' + } + } + ] +} diff --git a/src/components/rich_content/rich_content.scss b/src/components/rich_content/rich_content.scss index e5d353ac..3bb5b16b 100644 --- a/src/components/rich_content/rich_content.scss +++ b/src/components/rich_content/rich_content.scss @@ -65,4 +65,12 @@ vertical-align: middle; object-fit: contain; } + + .greentext { + color: var(--funtextGreentext); + } + + .cyantext { + color: var(--funtextCyantext); + } } diff --git a/src/components/status_body/status_body.scss b/src/components/status_body/status_body.scss index a8878745..930ed803 100644 --- a/src/components/status_body/status_body.scss +++ b/src/components/status_body/status_body.scss @@ -112,14 +112,6 @@ } } - .greentext { - color: var(--textGreentext); - } - - .cyantext { - color: var(--textCyantext); - } - &.-compact { align-items: top; flex-direction: row; diff --git a/src/components/status_content/status_content.vue b/src/components/status_content/status_content.vue index e977d489..a9db6b12 100644 --- a/src/components/status_content/status_content.vue +++ b/src/components/status_content/status_content.vue @@ -62,5 +62,15 @@ .StatusContent { flex: 1; min-width: 0; + + &.faint { + .greentext { + color: var(--funtextGreentextFaint); + } + + .cyantext { + color: var(--funtextCyantextFaint); + } + } } diff --git a/src/components/text.style.js b/src/components/text.style.js index 905dbbee..a254ceb4 100644 --- a/src/components/text.style.js +++ b/src/components/text.style.js @@ -2,34 +2,21 @@ export default { name: 'Text', selector: '/*text*/', virtual: true, - variants: { - greentext: '.greentext' - }, states: { faint: '.faint' }, defaultRules: [ { - component: 'Text', directives: { textColor: '--text', textAuto: 'no-preserve' } }, { - component: 'Text', state: ['faint'], directives: { textOpacity: 0.5 } - }, - { - component: 'Text', - variant: 'greentext', - directives: { - textColor: '--cGreen', - textAuto: 'preserve' - } } ] } diff --git a/src/services/theme_data/theme_data_3.service.js b/src/services/theme_data/theme_data_3.service.js index 0d205c73..9cab6dd4 100644 --- a/src/services/theme_data/theme_data_3.service.js +++ b/src/services/theme_data/theme_data_3.service.js @@ -19,9 +19,13 @@ import Button from 'src/components/button.style.js' import ButtonUnstyled from 'src/components/button_unstyled.style.js' import Input from 'src/components/input.style.js' import Text from 'src/components/text.style.js' +import FunText from 'src/components/fun_text.style.js' import Link from 'src/components/link.style.js' import Icon from 'src/components/icon.style.js' import Border from 'src/components/border.style.js' +import Post from 'src/components/post.style.js' +import Notification from 'src/components/notification.style.js' +import RichContent from 'src/components/rich_content.style.js' const DEBUG = false @@ -39,6 +43,7 @@ export const DEFAULT_SHADOWS = { const components = { Root, Text, + FunText, Link, Icon, Border, @@ -51,7 +56,10 @@ const components = { TopBar, Button, ButtonUnstyled, - Input + Input, + Post, + Notification, + RichContent } // "Unrolls" a tree structure of item: { parent: { ...item2, parent: { ...item3, parent: {...} } }} @@ -582,6 +590,7 @@ export const init = (extraRuleset, palette) => { ].join(';\n') } case 'textColor': { + if (rule.directives.textNoCssColor === 'yes') { return '' } return 'color: ' + v } default: return '' @@ -594,7 +603,7 @@ export const init = (extraRuleset, palette) => { return [ header, directives + ';', - !rule.virtual ? ' color: var(--text);' : '', + (!rule.virtual && rule.directives.textNoCssColor !== 'yes') ? ' color: var(--text);' : '', '', virtualDirectives, footer -- cgit v1.2.3-70-g09d2 From 3e198526e66b88301882b14240f0d50b8819b520 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 18 Feb 2024 18:40:14 +0200 Subject: dynamically load .style.js files; move the files closer to related components --- src/components/attachment/attachment.style.js | 15 ++++++ src/components/avatar.style.js | 22 -------- src/components/button.style.js | 2 +- src/components/button_unstyled.style.js | 2 +- src/components/chat/chat.scss | 12 +---- src/components/input.style.js | 2 +- src/components/modal/modals.style.js | 9 ++++ src/components/modals.style.js | 9 ---- src/components/notification.style.js | 22 -------- src/components/notification/notification.style.js | 23 ++++++++ src/components/poll/poll_graph.style.js | 14 +++++ src/components/post.style.js | 22 -------- src/components/rich_content.style.js | 17 ------ src/components/rich_content/rich_content.style.js | 17 ++++++ src/components/status/post.style.js | 24 +++++++++ src/components/user_avatar/avatar.style.js | 22 ++++++++ src/services/theme_data/theme_data_3.service.js | 65 +++++++---------------- 17 files changed, 147 insertions(+), 152 deletions(-) create mode 100644 src/components/attachment/attachment.style.js delete mode 100644 src/components/avatar.style.js create mode 100644 src/components/modal/modals.style.js delete mode 100644 src/components/modals.style.js delete mode 100644 src/components/notification.style.js create mode 100644 src/components/notification/notification.style.js create mode 100644 src/components/poll/poll_graph.style.js delete mode 100644 src/components/post.style.js delete mode 100644 src/components/rich_content.style.js create mode 100644 src/components/rich_content/rich_content.style.js create mode 100644 src/components/status/post.style.js create mode 100644 src/components/user_avatar/avatar.style.js (limited to 'src/components/notification') diff --git a/src/components/attachment/attachment.style.js b/src/components/attachment/attachment.style.js new file mode 100644 index 00000000..b76b3eb0 --- /dev/null +++ b/src/components/attachment/attachment.style.js @@ -0,0 +1,15 @@ +export default { + name: 'Attachment', + selector: '.Attachment', + validInnerComponents: [ + 'Border', + 'ButtonUnstyled' + ], + defaultRules: [ + { + directives: { + roundness: 3 + } + } + ] +} diff --git a/src/components/avatar.style.js b/src/components/avatar.style.js deleted file mode 100644 index 812d45a4..00000000 --- a/src/components/avatar.style.js +++ /dev/null @@ -1,22 +0,0 @@ -export default { - name: 'Avatar', - selector: '.Avatar', - variants: { - compact: '.-compact' - }, - defaultRules: [ - { - directives: { - roundness: 3, - shadow: [{ - x: 0, - y: 1, - blur: 8, - spread: 0, - color: '#000000', - alpha: 0.7 - }] - } - } - ] -} diff --git a/src/components/button.style.js b/src/components/button.style.js index 9f238b4e..6560c8fb 100644 --- a/src/components/button.style.js +++ b/src/components/button.style.js @@ -40,7 +40,7 @@ export default { // normal: '' // normal state is implicitly added, it is always included toggled: '.toggled', pressed: ':active', - hover: ':hover', + hover: ':hover:not(:disabled)', focused: ':focus-within', disabled: ':disabled' }, diff --git a/src/components/button_unstyled.style.js b/src/components/button_unstyled.style.js index e80322eb..89e8499c 100644 --- a/src/components/button_unstyled.style.js +++ b/src/components/button_unstyled.style.js @@ -5,7 +5,7 @@ export default { disabled: ':disabled', toggled: '.toggled', pressed: ':active', - hover: ':hover', + hover: ':hover:not(:disabled)', focused: ':focus-within' }, validInnerComponents: [ diff --git a/src/components/chat/chat.scss b/src/components/chat/chat.scss index 4f8f8492..31061409 100644 --- a/src/components/chat/chat.scss +++ b/src/components/chat/chat.scss @@ -11,7 +11,6 @@ .chat-view-body { box-sizing: border-box; - background-color: var(--chatBg, $fallback--bg); display: flex; flex-direction: column; width: 100%; @@ -38,8 +37,7 @@ .footer { position: sticky; bottom: 0; - background-color: $fallback--bg; - background-color: var(--bg, $fallback--bg); + background-color: var(--background); z-index: 1; } @@ -62,8 +60,6 @@ position: absolute; right: 1.3em; top: -3.2em; - background-color: $fallback--fg; - background-color: var(--btn, $fallback--fg); display: flex; justify-content: center; align-items: center; @@ -80,12 +76,6 @@ visibility: visible; } - i { - font-size: 1em; - color: $fallback--text; - color: var(--text, $fallback--text); - } - .unread-message-count { font-size: 0.8em; left: 50%; diff --git a/src/components/input.style.js b/src/components/input.style.js index 9cddfd8e..7db50b66 100644 --- a/src/components/input.style.js +++ b/src/components/input.style.js @@ -24,7 +24,7 @@ export default { selector: '.input', states: { disabled: ':disabled', - hover: ':hover', + hover: ':hover:not(:disabled)', focused: ':focus-within' }, validInnerComponents: [ diff --git a/src/components/modal/modals.style.js b/src/components/modal/modals.style.js new file mode 100644 index 00000000..c401a0cd --- /dev/null +++ b/src/components/modal/modals.style.js @@ -0,0 +1,9 @@ +export default { + name: 'Modals', + selector: '.modal-view', + lazy: true, + validInnerComponents: [ + 'Panel' + ], + defaultRules: [] +} diff --git a/src/components/modals.style.js b/src/components/modals.style.js deleted file mode 100644 index c401a0cd..00000000 --- a/src/components/modals.style.js +++ /dev/null @@ -1,9 +0,0 @@ -export default { - name: 'Modals', - selector: '.modal-view', - lazy: true, - validInnerComponents: [ - 'Panel' - ], - defaultRules: [] -} diff --git a/src/components/notification.style.js b/src/components/notification.style.js deleted file mode 100644 index 0802da77..00000000 --- a/src/components/notification.style.js +++ /dev/null @@ -1,22 +0,0 @@ -export default { - name: 'Notification', - selector: '.Notification', - validInnerComponents: [ - 'Text', - 'Link', - 'Icon', - 'Border', - 'Button', - 'ButtonUnstyled', - 'RichContent', - 'Input', - 'Avatar' - ], - defaultRules: [ - { - directives: { - background: '--bg' - } - } - ] -} diff --git a/src/components/notification/notification.style.js b/src/components/notification/notification.style.js new file mode 100644 index 00000000..ad7aab65 --- /dev/null +++ b/src/components/notification/notification.style.js @@ -0,0 +1,23 @@ +export default { + name: 'Notification', + selector: '.Notification', + validInnerComponents: [ + 'Text', + 'Link', + 'Icon', + 'Border', + 'Button', + 'ButtonUnstyled', + 'RichContent', + 'Input', + 'Avatar', + 'Attachment' + ], + defaultRules: [ + { + directives: { + background: '--bg' + } + } + ] +} diff --git a/src/components/poll/poll_graph.style.js b/src/components/poll/poll_graph.style.js new file mode 100644 index 00000000..01b4d35c --- /dev/null +++ b/src/components/poll/poll_graph.style.js @@ -0,0 +1,14 @@ +export default { + name: 'PollGraph', + selector: '.poll-graph', + validInnerComponents: [ + 'Text' + ], + defaultRules: [ + { + directives: { + background: '--accent' + } + } + ] +} diff --git a/src/components/post.style.js b/src/components/post.style.js deleted file mode 100644 index f4bd12a6..00000000 --- a/src/components/post.style.js +++ /dev/null @@ -1,22 +0,0 @@ -export default { - name: 'Post', - selector: '.Status', - validInnerComponents: [ - 'Text', - 'Link', - 'Icon', - 'Border', - 'Button', - 'ButtonUnstyled', - 'RichContent', - 'Input', - 'Avatar' - ], - defaultRules: [ - { - directives: { - background: '--bg' - } - } - ] -} diff --git a/src/components/rich_content.style.js b/src/components/rich_content.style.js deleted file mode 100644 index aaf126a5..00000000 --- a/src/components/rich_content.style.js +++ /dev/null @@ -1,17 +0,0 @@ -export default { - name: 'RichContent', - selector: '.RichContent', - validInnerComponents: [ - 'Text', - 'FunText', - 'Link' - ], - defaultRules: [ - { - directives: { - background: '--bg', - textNoCssColor: 'yes' - } - } - ] -} diff --git a/src/components/rich_content/rich_content.style.js b/src/components/rich_content/rich_content.style.js new file mode 100644 index 00000000..aaf126a5 --- /dev/null +++ b/src/components/rich_content/rich_content.style.js @@ -0,0 +1,17 @@ +export default { + name: 'RichContent', + selector: '.RichContent', + validInnerComponents: [ + 'Text', + 'FunText', + 'Link' + ], + defaultRules: [ + { + directives: { + background: '--bg', + textNoCssColor: 'yes' + } + } + ] +} diff --git a/src/components/status/post.style.js b/src/components/status/post.style.js new file mode 100644 index 00000000..dda79220 --- /dev/null +++ b/src/components/status/post.style.js @@ -0,0 +1,24 @@ +export default { + name: 'Post', + selector: '.Status', + validInnerComponents: [ + 'Text', + 'Link', + 'Icon', + 'Border', + 'Button', + 'ButtonUnstyled', + 'RichContent', + 'Input', + 'Avatar', + 'Attachment', + 'PollGraph' + ], + defaultRules: [ + { + directives: { + background: '--bg' + } + } + ] +} diff --git a/src/components/user_avatar/avatar.style.js b/src/components/user_avatar/avatar.style.js new file mode 100644 index 00000000..812d45a4 --- /dev/null +++ b/src/components/user_avatar/avatar.style.js @@ -0,0 +1,22 @@ +export default { + name: 'Avatar', + selector: '.Avatar', + variants: { + compact: '.-compact' + }, + defaultRules: [ + { + directives: { + roundness: 3, + shadow: [{ + x: 0, + y: 1, + blur: 8, + spread: 0, + color: '#000000', + alpha: 0.7 + }] + } + } + ] +} diff --git a/src/services/theme_data/theme_data_3.service.js b/src/services/theme_data/theme_data_3.service.js index 41c77506..f84a61c9 100644 --- a/src/services/theme_data/theme_data_3.service.js +++ b/src/services/theme_data/theme_data_3.service.js @@ -7,56 +7,25 @@ import { relativeLuminance } from '../color_convert/color_convert.js' -import Root from 'src/components/root.style.js' -import TopBar from 'src/components/top_bar.style.js' -import Underlay from 'src/components/underlay.style.js' -import Popover from 'src/components/popover.style.js' -import Modals from 'src/components/modals.style.js' -import MenuItem from 'src/components/menu_item.style.js' -import Panel from 'src/components/panel.style.js' -import PanelHeader from 'src/components/panel_header.style.js' -import Button from 'src/components/button.style.js' -import ButtonUnstyled from 'src/components/button_unstyled.style.js' -import Input from 'src/components/input.style.js' -import Text from 'src/components/text.style.js' -import FunText from 'src/components/fun_text.style.js' -import Link from 'src/components/link.style.js' -import Icon from 'src/components/icon.style.js' -import Border from 'src/components/border.style.js' -import Post from 'src/components/post.style.js' -import Notification from 'src/components/notification.style.js' -import RichContent from 'src/components/rich_content.style.js' -import Avatar from 'src/components/avatar.style.js' -import Badge from 'src/components/badge.style.js' -import Alert from 'src/components/alert.style.js' - const DEBUG = false +// Ensuring the order of components const components = { - Root, - Text, - FunText, - Link, - Icon, - Border, - Underlay, - Modals, - Popover, - MenuItem, - Panel, - PanelHeader, - TopBar, - Button, - ButtonUnstyled, - Input, - Post, - Notification, - RichContent, - Avatar, - Alert, - Badge + Root: null, + Text: null, + FunText: null, + Link: null, + Icon: null, + Border: null } +// Loading all style.js[on] files dynamically +const componentsContext = require.context('src', true, /\.style.js(on)?$/) +componentsContext.keys().forEach(key => { + const component = componentsContext(key).default + components[component.name] = component +}) + // "Unrolls" a tree structure of item: { parent: { ...item2, parent: { ...item3, parent: {...} } }} // into an array [item2, item3] for iterating const unroll = (item) => { @@ -370,7 +339,11 @@ export const init = (extraRuleset, palette) => { // Normalizing states and variants to always include "normal" const states = { normal: '', ...originalStates } const variants = { normal: '', ...originalVariants } - const innerComponents = (validInnerComponents).map(name => components[name]) + const innerComponents = (validInnerComponents).map(name => { + const result = components[name] + if (result === undefined) console.error(`Component ${component.name} references a component ${name} which does not exist!`) + return result + }) // Optimization: we only really need combinations without "normal" because all states implicitly have it const permutationStateKeys = Object.keys(states).filter(s => s !== 'normal') -- cgit v1.2.3-70-g09d2 From 11fd220734ae697e8157d25fbf4cdfc250fe2df7 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 19 Feb 2024 15:11:59 +0200 Subject: chat styles + related improvements --- src/components/chat/chat.style.js | 14 +++++++++ src/components/chat/chat.vue | 2 +- src/components/chat_message/chat_message.scss | 38 +++-------------------- src/components/chat_message/chat_message.style.js | 30 ++++++++++++++++++ src/components/notification/notification.style.js | 8 +---- src/components/panel.style.js | 3 +- src/components/panel_header.style.js | 3 +- src/components/rich_content/rich_content.style.js | 1 - src/components/status/post.style.js | 8 +---- src/services/theme_data/theme_data_3.service.js | 34 +++++++++----------- 10 files changed, 69 insertions(+), 72 deletions(-) create mode 100644 src/components/chat/chat.style.js create mode 100644 src/components/chat_message/chat_message.style.js (limited to 'src/components/notification') diff --git a/src/components/chat/chat.style.js b/src/components/chat/chat.style.js new file mode 100644 index 00000000..fc3d66a4 --- /dev/null +++ b/src/components/chat/chat.style.js @@ -0,0 +1,14 @@ +export default { + name: 'Chat', + selector: '.chat-message-list', + lazy: true, + validInnerComponents: [ + 'Text', + 'Link', + 'Icon', + 'Avatar', + 'ChatMessage' + ], + defaultRules: [ + ] +} diff --git a/src/components/chat/chat.vue b/src/components/chat/chat.vue index fc94cc71..65f89c73 100644 --- a/src/components/chat/chat.vue +++ b/src/components/chat/chat.vue @@ -26,7 +26,7 @@