From 6da4b19c0e1f70f8d74dd8ddcc77a3b1bc7c6453 Mon Sep 17 00:00:00 2001 From: Sam <51686767+samuveth@users.noreply.github.com> Date: Wed, 22 Nov 2023 08:46:23 +0700 Subject: [PATCH 01/20] ref: Major refactor Tune into Snapshot (#4374) --- package.json | 2 +- src/{style.scss => assets/css/main.scss} | 136 +------------ src/assets/css/tippy.scss | 87 +++++++++ src/assets/css/tune.scss | 181 ++++++++++++++++++ src/assets/icons/spinner.svg | 1 + src/components/BaseCalendar.vue | 2 +- src/components/BaseIndicator.vue | 2 +- src/components/BaseProgressBar.vue | 2 +- src/components/BlockSpacesListItem.vue | 2 +- src/components/InputCheckbox.vue | 2 +- src/components/ModalSpacesListItem.vue | 2 +- .../ProfileAboutDelegateListItem.vue | 2 +- src/components/ProfileActivityListItem.vue | 2 +- src/components/SetupSidebarStepper.vue | 12 +- .../SpaceProposalResultsProgressBar.vue | 2 +- src/components/TheNavbar.vue | 4 +- src/components/Tune/TuneButton.story.vue | 5 + src/components/Tune/TuneButton.vue | 34 ++++ .../Tune/TuneButtonSelect.story.vue | 5 + src/components/Tune/TuneButtonSelect.vue | 35 ++++ src/components/Tune/TuneCheckbox.story.vue | 15 ++ src/components/Tune/TuneCheckbox.vue | 36 ++++ src/components/Tune/TuneCombobox.story.vue | 18 ++ src/components/Tune/TuneCombobox.vue | 148 ++++++++++++++ .../Tune/TuneComboboxMultiple.story.vue | 18 ++ src/components/Tune/TuneComboboxMultiple.vue | 157 +++++++++++++++ src/components/Tune/TuneErrorInput.story.vue | 7 + src/components/Tune/TuneErrorInput.vue | 11 ++ src/components/Tune/TuneForm.story.vue | 100 ++++++++++ src/components/Tune/TuneForm.vue | 63 ++++++ src/components/Tune/TuneIconHint.story.vue | 11 ++ src/components/Tune/TuneIconHint.vue | 11 ++ src/components/Tune/TuneInput.story.vue | 7 + src/components/Tune/TuneInput.vue | 118 ++++++++++++ .../Tune/TuneInputDuration.story.vue | 21 ++ src/components/Tune/TuneInputDuration.vue | 135 +++++++++++++ src/components/Tune/TuneInputSocial.vue | 44 +++++ src/components/Tune/TuneInputUrl.vue | 42 ++++ src/components/Tune/TuneLabelInput.story.vue | 12 ++ src/components/Tune/TuneLabelInput.vue | 18 ++ src/components/Tune/TuneListbox.story.vue | 15 ++ src/components/Tune/TuneListbox.vue | 137 +++++++++++++ .../Tune/TuneListboxMultiple.story.vue | 15 ++ src/components/Tune/TuneListboxMultiple.vue | 158 +++++++++++++++ .../Tune/TuneLoadingSpinner.story.vue | 7 + src/components/Tune/TuneLoadingSpinner.vue | 7 + src/components/Tune/TuneMenu.story.vue | 26 +++ src/components/Tune/TuneMenu.vue | 70 +++++++ src/components/Tune/TuneModal.story.vue | 38 ++++ src/components/Tune/TuneModal.vue | 66 +++++++ src/components/Tune/TunePopover.story.vue | 17 ++ src/components/Tune/TunePopover.vue | 56 ++++++ src/components/Tune/TuneRadio.story.vue | 22 +++ src/components/Tune/TuneRadio.vue | 39 ++++ src/components/Tune/TuneSelect.vue | 31 +++ src/components/Tune/TuneSwitch.story.vue | 14 ++ src/components/Tune/TuneSwitch.vue | 94 +++++++++ src/components/Tune/TuneTag.story.vue | 7 + src/components/Tune/TuneTag.vue | 11 ++ src/components/Tune/TuneTextarea.story.vue | 13 ++ src/components/Tune/TuneTextarea.vue | 101 ++++++++++ .../Tune/TuneTextareaArray.story.vue | 13 ++ src/components/Tune/TuneTextareaArray.vue | 45 +++++ .../Tune/TuneTextareaJson.story.vue | 13 ++ src/components/Tune/TuneTextareaJson.vue | 51 +++++ src/components/Tune/_Form/FormArray.vue | 113 +++++++++++ src/components/Tune/_Form/FormBoolean.vue | 22 +++ src/components/Tune/_Form/FormNumber.vue | 34 ++++ src/components/Tune/_Form/FormString.vue | 61 ++++++ src/main.ts | 3 +- src/vars.scss | 0 tailwind.config.js | 2 +- vite.config.ts | 14 +- yarn.lock | 58 ++---- 74 files changed, 2677 insertions(+), 208 deletions(-) rename src/{style.scss => assets/css/main.scss} (60%) create mode 100644 src/assets/css/tippy.scss create mode 100644 src/assets/css/tune.scss create mode 100644 src/assets/icons/spinner.svg create mode 100644 src/components/Tune/TuneButton.story.vue create mode 100644 src/components/Tune/TuneButton.vue create mode 100644 src/components/Tune/TuneButtonSelect.story.vue create mode 100644 src/components/Tune/TuneButtonSelect.vue create mode 100644 src/components/Tune/TuneCheckbox.story.vue create mode 100644 src/components/Tune/TuneCheckbox.vue create mode 100644 src/components/Tune/TuneCombobox.story.vue create mode 100644 src/components/Tune/TuneCombobox.vue create mode 100644 src/components/Tune/TuneComboboxMultiple.story.vue create mode 100644 src/components/Tune/TuneComboboxMultiple.vue create mode 100644 src/components/Tune/TuneErrorInput.story.vue create mode 100644 src/components/Tune/TuneErrorInput.vue create mode 100644 src/components/Tune/TuneForm.story.vue create mode 100644 src/components/Tune/TuneForm.vue create mode 100644 src/components/Tune/TuneIconHint.story.vue create mode 100644 src/components/Tune/TuneIconHint.vue create mode 100644 src/components/Tune/TuneInput.story.vue create mode 100644 src/components/Tune/TuneInput.vue create mode 100644 src/components/Tune/TuneInputDuration.story.vue create mode 100644 src/components/Tune/TuneInputDuration.vue create mode 100644 src/components/Tune/TuneInputSocial.vue create mode 100644 src/components/Tune/TuneInputUrl.vue create mode 100644 src/components/Tune/TuneLabelInput.story.vue create mode 100644 src/components/Tune/TuneLabelInput.vue create mode 100644 src/components/Tune/TuneListbox.story.vue create mode 100644 src/components/Tune/TuneListbox.vue create mode 100644 src/components/Tune/TuneListboxMultiple.story.vue create mode 100644 src/components/Tune/TuneListboxMultiple.vue create mode 100644 src/components/Tune/TuneLoadingSpinner.story.vue create mode 100644 src/components/Tune/TuneLoadingSpinner.vue create mode 100644 src/components/Tune/TuneMenu.story.vue create mode 100644 src/components/Tune/TuneMenu.vue create mode 100644 src/components/Tune/TuneModal.story.vue create mode 100644 src/components/Tune/TuneModal.vue create mode 100644 src/components/Tune/TunePopover.story.vue create mode 100644 src/components/Tune/TunePopover.vue create mode 100644 src/components/Tune/TuneRadio.story.vue create mode 100644 src/components/Tune/TuneRadio.vue create mode 100644 src/components/Tune/TuneSelect.vue create mode 100644 src/components/Tune/TuneSwitch.story.vue create mode 100644 src/components/Tune/TuneSwitch.vue create mode 100644 src/components/Tune/TuneTag.story.vue create mode 100644 src/components/Tune/TuneTag.vue create mode 100644 src/components/Tune/TuneTextarea.story.vue create mode 100644 src/components/Tune/TuneTextarea.vue create mode 100644 src/components/Tune/TuneTextareaArray.story.vue create mode 100644 src/components/Tune/TuneTextareaArray.vue create mode 100644 src/components/Tune/TuneTextareaJson.story.vue create mode 100644 src/components/Tune/TuneTextareaJson.vue create mode 100644 src/components/Tune/_Form/FormArray.vue create mode 100644 src/components/Tune/_Form/FormBoolean.vue create mode 100644 src/components/Tune/_Form/FormNumber.vue create mode 100644 src/components/Tune/_Form/FormString.vue delete mode 100644 src/vars.scss diff --git a/package.json b/package.json index 48ba0359b..9192c4a95 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,6 @@ "@snapshot-labs/lock": "^0.2.1", "@snapshot-labs/pineapple": "^1.1.0", "@snapshot-labs/snapshot.js": "^0.9.2", - "@snapshot-labs/tune": "^0.1.34", "@vue/apollo-composable": "4.0.0-beta.11", "@vueuse/core": "^10.6.1", "@vueuse/head": "^2.0.0", @@ -52,6 +51,7 @@ "js-sha256": "^0.10.1", "jsonexport": "^3.2.0", "lodash": "^4.17.21", + "minisearch": "^6.2.0", "mixpanel-browser": "^2.48.1", "remarkable": "^2.0.1", "remove-markdown": "^0.5.0", diff --git a/src/style.scss b/src/assets/css/main.scss similarity index 60% rename from src/style.scss rename to src/assets/css/main.scss index 8f3485827..a5977e2c9 100644 --- a/src/style.scss +++ b/src/assets/css/main.scss @@ -1,4 +1,6 @@ -@import './assets/fonts/iconfont.css'; +@import '../fonts/iconfont.css'; +@import './tippy.scss'; +@import './tune.scss'; @tailwind base; @tailwind components; @@ -33,21 +35,21 @@ @layer base { @font-face { font-family: 'Calibre'; - src: url('./assets/fonts/Calibre-Medium-Custom.woff2') format('woff2'); + src: url('../fonts/Calibre-Medium-Custom.woff2') format('woff2'); font-weight: 500; font-style: normal; } @font-face { font-family: 'Calibre'; - src: url('./assets/fonts/Calibre-Semibold-Custom.woff2') format('woff2'); + src: url('../fonts/Calibre-Semibold-Custom.woff2') format('woff2'); font-weight: 600; font-style: normal; } @font-face { font-family: 'SpaceMono'; - src: url('./assets/fonts/space-mono-v11-latin-700.woff2') format('woff2'); + src: url('../fonts/space-mono-v11-latin-700.woff2') format('woff2'); } html { @@ -115,44 +117,6 @@ } } -// Tune component styles - -.tune-label { - @apply font-sans; -} - -.tune-sublabel { - @apply font-sans; -} - -.tune-button { - @apply rounded-full; -} - -.tune-input { - @apply rounded-full; -} - -.tune-textarea { - @apply rounded-3xl px-3; -} - -.tune-listbox-button { - @apply rounded-full; -} - -.tune-button-select { - @apply rounded-full; -} - -.tune-input-duration { - @apply rounded-full; -} - -.tune-error-text { - @apply font-sans; -} - // Fade transition for Vue's transition and transition-group .fade-enter-active, .fade-leave-active { @@ -219,94 +183,6 @@ input[type='number'] { -moz-appearance: textfield; } -// V-Tippy tooltip package styling - could be moved somewhere else? -.tippy-box[data-animation='fade'][data-state='hidden'] { - opacity: 0; -} -[data-tippy-root] { - max-width: calc(100vw - 10px); -} -.tippy-box { - position: relative; - background-color: var(--text-color); - color: var(--header-bg); - border-radius: 7px; - font-size: 16px; - line-height: 1.4; - outline: 0; - transition-property: transform, visibility, opacity; - padding: 2px 4px; - text-align: center; - font-weight: 500; -} -.tippy-box[data-placement^='top'] > .tippy-arrow { - bottom: 0; -} -.tippy-box[data-placement^='top'] > .tippy-arrow:before { - bottom: -7px; - left: 0; - border-width: 8px 8px 0; - border-top-color: var(--text-color); - transform-origin: center top; -} -.tippy-box[data-placement^='bottom'] > .tippy-arrow { - top: 0; -} -.tippy-box[data-placement^='bottom'] > .tippy-arrow:before { - top: -7px; - left: 0; - border-width: 0 8px 8px; - border-bottom-color: var(--text-color); - transform-origin: center bottom; -} -.tippy-box[data-placement^='left'] > .tippy-arrow { - right: 0; -} -.tippy-box[data-placement^='left'] > .tippy-arrow:before { - border-width: 8px 0 8px 8px; - border-left-color: var(--text-color); - right: -7px; - transform-origin: center left; -} -.tippy-box[data-placement^='right'] > .tippy-arrow { - left: 0; -} -.tippy-box[data-placement^='right'] > .tippy-arrow:before { - left: -7px; - border-width: 8px 8px 8px 0; - border-right-color: var(--text-color); - transform-origin: center right; -} -.tippy-box[data-inertia][data-state='visible'] { - transition-timing-function: cubic-bezier(0.54, 1.5, 0.38, 1.11); -} -.tippy-arrow { - width: 16px; - height: 16px; - color: #333; -} -.tippy-arrow:before { - content: ''; - position: absolute; - border-color: transparent; - border-style: solid; -} -.tippy-content { - position: relative; - padding: 5px 9px; - z-index: 1; - overflow-wrap: break-word; -} -.tippy-box[data-theme~='urlified'] { - max-width: 200px; - white-space: pre-wrap; - color: var(--header-bg); - - a { - color: var(--header-bg); - } -} - .lazy-loading { @apply animate-pulse-fast bg-skin-border; } diff --git a/src/assets/css/tippy.scss b/src/assets/css/tippy.scss new file mode 100644 index 000000000..0455b0265 --- /dev/null +++ b/src/assets/css/tippy.scss @@ -0,0 +1,87 @@ +// V-Tippy tooltip package styling - could be moved somewhere else? +.tippy-box[data-animation='fade'][data-state='hidden'] { + opacity: 0; +} +[data-tippy-root] { + max-width: calc(100vw - 10px); +} +.tippy-box { + position: relative; + background-color: var(--text-color); + color: var(--header-bg); + border-radius: 7px; + font-size: 16px; + line-height: 1.4; + outline: 0; + transition-property: transform, visibility, opacity; + padding: 2px 4px; + text-align: center; + font-weight: 500; +} +.tippy-box[data-placement^='top'] > .tippy-arrow { + bottom: 0; +} +.tippy-box[data-placement^='top'] > .tippy-arrow:before { + bottom: -7px; + left: 0; + border-width: 8px 8px 0; + border-top-color: var(--text-color); + transform-origin: center top; +} +.tippy-box[data-placement^='bottom'] > .tippy-arrow { + top: 0; +} +.tippy-box[data-placement^='bottom'] > .tippy-arrow:before { + top: -7px; + left: 0; + border-width: 0 8px 8px; + border-bottom-color: var(--text-color); + transform-origin: center bottom; +} +.tippy-box[data-placement^='left'] > .tippy-arrow { + right: 0; +} +.tippy-box[data-placement^='left'] > .tippy-arrow:before { + border-width: 8px 0 8px 8px; + border-left-color: var(--text-color); + right: -7px; + transform-origin: center left; +} +.tippy-box[data-placement^='right'] > .tippy-arrow { + left: 0; +} +.tippy-box[data-placement^='right'] > .tippy-arrow:before { + left: -7px; + border-width: 8px 8px 8px 0; + border-right-color: var(--text-color); + transform-origin: center right; +} +.tippy-box[data-inertia][data-state='visible'] { + transition-timing-function: cubic-bezier(0.54, 1.5, 0.38, 1.11); +} +.tippy-arrow { + width: 16px; + height: 16px; + color: #333; +} +.tippy-arrow:before { + content: ''; + position: absolute; + border-color: transparent; + border-style: solid; +} +.tippy-content { + position: relative; + padding: 5px 9px; + z-index: 1; + overflow-wrap: break-word; +} +.tippy-box[data-theme~='urlified'] { + max-width: 200px; + white-space: pre-wrap; + color: var(--header-bg); + + a { + color: var(--header-bg); + } +} diff --git a/src/assets/css/tune.scss b/src/assets/css/tune.scss new file mode 100644 index 000000000..fd6ccbc99 --- /dev/null +++ b/src/assets/css/tune.scss @@ -0,0 +1,181 @@ +.tune-input { + @apply form-input rounded-full border-skin-border bg-transparent text-base text-skin-link focus:border-skin-text focus:outline-none focus:ring-0; +} + +.tune-textarea { + @extend .tune-input; + @apply no-scrollbar rounded-3xl px-3; + + &.disabled { + @apply cursor-not-allowed; + } +} + +.tune-textarea-json { + @apply no-scrollbar overflow-x-scroll whitespace-pre; + + &.disabled { + @apply cursor-not-allowed; + } +} + +.tune-switch { + @apply border-transparent; + + &.switched-on-bg { + @apply bg-green; + } + &.switched-off-bg { + @apply bg-skin-border; + } + + &.switched-on-text { + @apply text-green; + } + &.switched-off-text { + @apply text-skin-text; + } +} + +.tune-switch-button { + @apply bg-skin-bg; +} + +.tune-input-loading { + @apply rounded-r-full bg-skin-bg; +} + +.tune-button { + @apply flex h-[42px] cursor-pointer justify-center rounded-full border border-skin-border px-3 py-2 hover:border-skin-text disabled:cursor-not-allowed; + + &.primary { + @apply border-skin-primary bg-skin-primary text-white; + } + + &.disabled { + @apply border-skin-border bg-skin-bg text-skin-border; + } +} + +.tune-button-select { + @apply relative flex w-full justify-start truncate pl-3 pr-5 text-left text-base text-skin-link rounded-full; + + &.disabled { + @apply cursor-not-allowed border-skin-border; + } +} + +.tune-input-duration { + @apply rounded-full border border-skin-border px-3 text-base text-skin-link focus-within:border-skin-text; + &.disabled { + @apply cursor-not-allowed; + } +} + +.tune-input-duration-label { + @apply text-skin-text; +} + +.tune-select { + @apply text-left; + + &.disabled { + @apply cursor-not-allowed; + } +} + +.tune-listbox-button { + @apply rounded-full border border-skin-border text-base text-skin-link hover:border-skin-text; + + &.disabled { + @apply hover:border-skin-border; + } + + &.error { + @apply border-red; + } +} + +.tune-listbox-options { + @apply rounded-md border border-skin-border bg-skin-bg shadow-lg; +} + +.tune-listbox-item { + &.selected { + @apply text-skin-link; + } + &.disabled { + @apply text-skin-border; + } + &.active { + @apply bg-skin-border; + } +} + +.tune-listbox-placeholder { + @apply text-skin-text opacity-60; +} + +.tune-label { + @apply font-sans text-skin-text; +} + +.tune-sublabel { + @apply font-sans text-sm text-skin-text opacity-60; +} + +.tune-icon-hint { + @apply text-sm hover:text-skin-link; +} + +.tune-error-text { + @apply font-sans text-sm text-red; +} + +.tune-error-border { + @apply border-red; +} + +.tune-tag { + @apply rounded-md border border-skin-border bg-skin-border px-2 py-1 text-sm text-skin-text; +} + +.tune-menu-list { + @apply rounded-md border border-skin-border bg-skin-header-bg shadow-lg; +} + +.tune-menu-list-item { + @apply bg-skin-header-bg text-skin-text; + + &.active { + @apply bg-skin-border text-skin-link; + } +} + +.tune-popover { + @apply rounded-md border bg-skin-header-bg shadow-lg; +} + +.tune-modal-panel { + @apply rounded-md border border-skin-border bg-skin-bg p-4 sm:w-[440px]; +} + +.tune-modal-backdrop { + @apply bg-skin-border opacity-70; +} + +.tune-modal-title { + @apply text-center text-lg font-medium text-skin-text; +} + +.tune-input-checkbox { + @apply form-checkbox h-[20px] w-[20px] rounded-lg border-skin-text bg-skin-bg text-skin-primary focus:ring-0 focus:ring-offset-0 focus-visible:ring-offset-1 focus-visible:ring-offset-skin-text; +} + +.tune-input-radio { + @apply form-radio h-[20px] w-[20px] rounded-full border-skin-text bg-skin-bg text-skin-primary focus:ring-0 focus:ring-offset-0 focus-visible:ring-offset-1 focus-visible:ring-offset-skin-text; +} + +.tune-form-array-objects { + @apply rounded-xl border p-3; +} diff --git a/src/assets/icons/spinner.svg b/src/assets/icons/spinner.svg new file mode 100644 index 000000000..ccb5e4da3 --- /dev/null +++ b/src/assets/icons/spinner.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/BaseCalendar.vue b/src/components/BaseCalendar.vue index cf5536517..ef182ca01 100644 --- a/src/components/BaseCalendar.vue +++ b/src/components/BaseCalendar.vue @@ -102,7 +102,7 @@ function isSelectable(year, month, day) { v-if="isSelectable(year, month, day)" class="day border-b border-r bg-transparent text-skin-link hover:bg-skin-link hover:text-skin-bg" :class="{ - 'ring-1 ring-inset ring-primary': + 'ring-1 ring-inset ring-skin-primary': formatDate(year, month, day) === today, '!bg-skin-link !text-skin-bg': input.includes( formatDate(year, month, day) diff --git a/src/components/BaseIndicator.vue b/src/components/BaseIndicator.vue index fddf5171f..d5362a05f 100644 --- a/src/components/BaseIndicator.vue +++ b/src/components/BaseIndicator.vue @@ -1,3 +1,3 @@ diff --git a/src/components/BaseProgressBar.vue b/src/components/BaseProgressBar.vue index a6d9ec357..afdb0477b 100644 --- a/src/components/BaseProgressBar.vue +++ b/src/components/BaseProgressBar.vue @@ -7,7 +7,7 @@ defineProps<{ value: number }>();
diff --git a/src/components/BlockSpacesListItem.vue b/src/components/BlockSpacesListItem.vue index f0050a8d4..3ae114b4b 100644 --- a/src/components/BlockSpacesListItem.vue +++ b/src/components/BlockSpacesListItem.vue @@ -27,7 +27,7 @@ defineProps<{
diff --git a/src/components/InputCheckbox.vue b/src/components/InputCheckbox.vue index 9a98fe2e8..4719c832d 100644 --- a/src/components/InputCheckbox.vue +++ b/src/components/InputCheckbox.vue @@ -14,7 +14,7 @@ const emit = defineEmits(['update:modelValue']); :checked="modelValue" :name="name" type="checkbox" - class="form-checkbox h-[19px] w-[19px] rounded-lg border-skin-text bg-skin-bg text-primary !outline-none !ring-0" + class="form-checkbox h-[19px] w-[19px] rounded-lg border-skin-text bg-skin-bg text-skin-primary !outline-none !ring-0" @input=" emit('update:modelValue', ($event.target as HTMLInputElement).checked) " diff --git a/src/components/ModalSpacesListItem.vue b/src/components/ModalSpacesListItem.vue index a1da229c0..71c93a00a 100644 --- a/src/components/ModalSpacesListItem.vue +++ b/src/components/ModalSpacesListItem.vue @@ -21,7 +21,7 @@ defineProps<{ diff --git a/src/components/ProfileAboutDelegateListItem.vue b/src/components/ProfileAboutDelegateListItem.vue index 71917c1d3..d54b61830 100644 --- a/src/components/ProfileAboutDelegateListItem.vue +++ b/src/components/ProfileAboutDelegateListItem.vue @@ -31,7 +31,7 @@ defineEmits(['delegate']); diff --git a/src/components/ProfileActivityListItem.vue b/src/components/ProfileActivityListItem.vue index a9c17512c..24010c1df 100644 --- a/src/components/ProfileActivityListItem.vue +++ b/src/components/ProfileActivityListItem.vue @@ -20,7 +20,7 @@ defineProps<{ activity: ProfileActivity }>();
diff --git a/src/components/SetupSidebarStepper.vue b/src/components/SetupSidebarStepper.vue index 44d79a2aa..63eaeb8ba 100644 --- a/src/components/SetupSidebarStepper.vue +++ b/src/components/SetupSidebarStepper.vue @@ -24,12 +24,12 @@ const steps = [