From 4c16efb33df1eff3364fc79a660f06fcc8e650b0 Mon Sep 17 00:00:00 2001 From: Keavon Chambers Date: Sun, 6 Nov 2022 00:50:45 -0700 Subject: [PATCH] Fix several CSS compatibility issues in Safari (#841) * Fix button margin default for Safari compatibility * Add Safari vendor prefixes that are somehow still necessary * Add workaround for Safari not rendering text selection * Replace

and

placeholder labels in floating menus with * Replace elements with and set its cursor for Safari --- frontend/src/App.vue | 24 ++------------ .../components/floating-menus/ColorPicker.vue | 1 + .../components/floating-menus/DialogModal.vue | 1 + .../components/floating-menus/MenuList.vue | 4 ++- frontend/src/components/panels/Document.vue | 2 +- frontend/src/components/panels/LayerTree.vue | 4 ++- frontend/src/components/panels/NodeGraph.vue | 7 +++- frontend/src/components/widgets/WidgetRow.vue | 4 +-- .../components/widgets/buttons/IconButton.vue | 4 ++- .../components/widgets/buttons/TextButton.vue | 3 +- .../widgets/groups/WidgetSection.vue | 1 + .../components/widgets/inputs/ColorInput.vue | 2 +- .../widgets/inputs/DropdownInput.vue | 20 ++++++------ .../components/widgets/inputs/FieldInput.vue | 11 ++++++- .../components/widgets/inputs/FontInput.vue | 6 ++-- .../widgets/inputs/MenuBarInput.vue | 4 ++- .../components/widgets/inputs/NumberInput.vue | 5 +-- .../components/widgets/inputs/RadioInput.vue | 1 + .../widgets/inputs/SwatchPairInput.vue | 4 +-- .../components/widgets/inputs/TextInput.vue | 2 +- .../components/widgets/labels/TextLabel.vue | 4 ++- .../widgets/labels/UserInputLabel.vue | 32 +++++++++++-------- .../widgets/metrics/PersistentScrollbar.vue | 1 + .../window/title-bar/WindowTitle.vue | 8 +++-- .../src/components/window/workspace/Panel.vue | 6 ++-- 25 files changed, 92 insertions(+), 69 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index d550bd53..6e0bc977 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -78,8 +78,9 @@ body, margin: 0; height: 100%; background: var(--color-2-mildblack); - user-select: none; overscroll-behavior: none; + -webkit-user-select: none; // Required as of Safari 15.0 (Graphite's minimum version) through the latest release + user-select: none; } html, @@ -223,27 +224,6 @@ img { outline: 1px dashed var(--color-2-mildblack); } } - -// For placeholder messages (remove eventually) -.floating-menu { - h1, - h2, - h3, - h4, - h5, - h6, - p { - margin: 0; - } - - p { - margin-top: 8px; - } - - .floating-menu-content h3 ~ p { - white-space: pre-wrap; - } -} diff --git a/frontend/src/components/widgets/inputs/FieldInput.vue b/frontend/src/components/widgets/inputs/FieldInput.vue index e8a17843..c9208385 100644 --- a/frontend/src/components/widgets/inputs/FieldInput.vue +++ b/frontend/src/components/widgets/inputs/FieldInput.vue @@ -80,7 +80,16 @@ caret-color: var(--color-e-nearwhite); &::selection { - background: var(--color-5-dullgray); + background-color: var(--color-5-dullgray); + + // Target only Safari + @supports (background: -webkit-named-image(i)) { + & { + // Setting an alpha value opts out of Safari's "fancy" (but not visible on dark backgrounds) selection highlight rendering + // https://stackoverflow.com/a/71753552/775283 + background-color: rgba(var(--color-5-dullgray-rgb), calc(254 / 255)); + } + } } } diff --git a/frontend/src/components/widgets/inputs/FontInput.vue b/frontend/src/components/widgets/inputs/FontInput.vue index 6c2bc6d9..9374b558 100644 --- a/frontend/src/components/widgets/inputs/FontInput.vue +++ b/frontend/src/components/widgets/inputs/FontInput.vue @@ -12,7 +12,7 @@ @keydown="keydown" data-floating-menu-spawner > - {{ activeEntry?.value || "" }} + {{ activeEntry?.value || "" }} diff --git a/frontend/src/components/widgets/inputs/MenuBarInput.vue b/frontend/src/components/widgets/inputs/MenuBarInput.vue index 0c55e1f1..bec7cef0 100644 --- a/frontend/src/components/widgets/inputs/MenuBarInput.vue +++ b/frontend/src/components/widgets/inputs/MenuBarInput.vue @@ -11,7 +11,7 @@ :data-floating-menu-spawner="entry.children && entry.children.length > 0 ? '' : 'no-hover-transfer'" > - {{ entry.label }} + {{ entry.label }} ; @@ -147,6 +148,7 @@ export default defineComponent({ components: { IconLabel, MenuList, + TextLabel, }, }); diff --git a/frontend/src/components/widgets/inputs/NumberInput.vue b/frontend/src/components/widgets/inputs/NumberInput.vue index ad5a901d..7d108843 100644 --- a/frontend/src/components/widgets/inputs/NumberInput.vue +++ b/frontend/src/components/widgets/inputs/NumberInput.vue @@ -59,6 +59,7 @@ .arrow { position: absolute; top: 0; + margin: 0; padding: 9px 0; border: none; background: rgba(var(--color-1-nearblack-rgb), 0.75); @@ -131,7 +132,7 @@ height: 100%; padding: 0; margin: 0; - -webkit-appearance: none; // TODO: Prefix necessary? Test on Safari + -webkit-appearance: none; // Required until Safari 15.4 (Graphite supports 15.0+) appearance: none; background: none; cursor: default; @@ -147,7 +148,7 @@ // Chromium and Safari &::-webkit-slider-thumb { - -webkit-appearance: none; // TODO: Prefix necessary? Test on Safari + -webkit-appearance: none; // Required until Safari 15.4 (Graphite supports 15.0+) appearance: none; border-radius: 2px; width: 4px; diff --git a/frontend/src/components/widgets/inputs/RadioInput.vue b/frontend/src/components/widgets/inputs/RadioInput.vue index dc739a07..fbef22e6 100644 --- a/frontend/src/components/widgets/inputs/RadioInput.vue +++ b/frontend/src/components/widgets/inputs/RadioInput.vue @@ -21,6 +21,7 @@ background: var(--color-5-dullgray); fill: var(--color-e-nearwhite); height: 24px; + margin: 0; padding: 0 4px; border: none; display: flex; diff --git a/frontend/src/components/widgets/inputs/SwatchPairInput.vue b/frontend/src/components/widgets/inputs/SwatchPairInput.vue index f8282236..019852a9 100644 --- a/frontend/src/components/widgets/inputs/SwatchPairInput.vue +++ b/frontend/src/components/widgets/inputs/SwatchPairInput.vue @@ -1,11 +1,11 @@ @@ -26,10 +26,6 @@ align-items: center; white-space: nowrap; - .group-gap { - width: 4px; - } - .input-key, .input-mouse { & + .input-key, @@ -46,14 +42,18 @@ font-weight: 400; text-align: center; height: 16px; - // Firefox renders the text 1px lower than Chrome (tested on Windows) with 16px line-height, so moving it up 1 pixel by using 15px makes them agree - line-height: 15px; box-sizing: border-box; border: 1px solid; border-radius: 4px; border-color: var(--color-5-dullgray); color: var(--color-e-nearwhite); + .text-label { + // Firefox renders the text 1px lower than Chrome (tested on Windows) with 16px line-height, + // so moving it up 1 pixel by using 15px makes them agree. + line-height: 15px; + } + &.width-1 { width: 16px; } @@ -131,6 +131,8 @@ import { type KeyRaw, type KeysGroup, type Key, type MouseMotion } from "@/wasm- import LayoutRow from "@/components/layout/LayoutRow.vue"; import IconLabel from "@/components/widgets/labels/IconLabel.vue"; +import Separator from "@/components/widgets/labels/Separator.vue"; +import TextLabel from "@/components/widgets/labels/TextLabel.vue"; type LabelData = { label?: string; icon?: IconName; width: string }; @@ -240,6 +242,8 @@ export default defineComponent({ components: { IconLabel, LayoutRow, + Separator, + TextLabel, }, }); diff --git a/frontend/src/components/widgets/metrics/PersistentScrollbar.vue b/frontend/src/components/widgets/metrics/PersistentScrollbar.vue index 435abd78..6831c8d5 100644 --- a/frontend/src/components/widgets/metrics/PersistentScrollbar.vue +++ b/frontend/src/components/widgets/metrics/PersistentScrollbar.vue @@ -20,6 +20,7 @@ border-style: solid; width: 0; height: 0; + margin: 0; padding: 0; } diff --git a/frontend/src/components/window/title-bar/WindowTitle.vue b/frontend/src/components/window/title-bar/WindowTitle.vue index 13467876..0674cd5f 100644 --- a/frontend/src/components/window/title-bar/WindowTitle.vue +++ b/frontend/src/components/window/title-bar/WindowTitle.vue @@ -1,6 +1,6 @@ @@ -17,11 +17,15 @@ import { defineComponent, type PropType } from "vue"; import LayoutRow from "@/components/layout/LayoutRow.vue"; +import TextLabel from "@/components/widgets/labels/TextLabel.vue"; export default defineComponent({ props: { text: { type: String as PropType, required: true }, }, - components: { LayoutRow }, + components: { + LayoutRow, + TextLabel, + }, }); diff --git a/frontend/src/components/window/workspace/Panel.vue b/frontend/src/components/window/workspace/Panel.vue index e366d60b..836cd640 100644 --- a/frontend/src/components/window/workspace/Panel.vue +++ b/frontend/src/components/window/workspace/Panel.vue @@ -12,13 +12,13 @@ @click.middle="(e: MouseEvent) => (e?.stopPropagation(), closeAction?.(tabIndex))" data-tab > - {{ tabLabel.name }} + {{ tabLabel.name }} -

Panel Options

-

The contents of this popover menu are coming soon

+ Panel Options + The contents of this popover menu are coming soon