From d0c0a543cfd196a4021e128a57957951efd53b7b Mon Sep 17 00:00:00 2001 From: liyasthomas Date: Tue, 3 Aug 2021 21:35:01 +0530 Subject: [PATCH] feat: font size picker --- assets/scss/styles.scss | 17 +++++-- assets/scss/themes.scss | 33 +++++++++++++ components/smart/AccentModePicker.vue | 1 - components/smart/ChangeLanguage.vue | 61 ++++++++++++------------ components/smart/FontSizePicker.vue | 68 +++++++++++++++++++++++++++ components/smart/Item.vue | 4 +- lang/en-US.json | 9 ++-- layouts/default.vue | 4 ++ layouts/error.vue | 2 +- newstore/settings.ts | 19 ++++++++ pages/settings.vue | 12 ++++- 11 files changed, 186 insertions(+), 44 deletions(-) create mode 100644 components/smart/FontSizePicker.vue diff --git a/assets/scss/styles.scss b/assets/scss/styles.scss index 2c327a3a7..e6ae18625 100644 --- a/assets/scss/styles.scss +++ b/assets/scss/styles.scss @@ -41,11 +41,13 @@ html { body { @apply bg-primary; - @apply text-secondary text-xs; + @apply text-secondary; @apply font-medium; @apply select-none; @apply overflow-x-hidden; + font-size: var(--font-size); + line-height: var(--line-height); overflow: overlay; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; @@ -162,16 +164,15 @@ hr { @apply text-secondaryDark text-lg; } -.textarea, .input, -.select { +.select, +.textarea { @apply flex flex-1; @apply w-full; @apply px-4 py-2; @apply bg-primary; @apply truncate; @apply rounded; - @apply text-xs; @apply font-semibold; @apply border border-divider; @apply transition; @@ -179,6 +180,14 @@ hr { @apply disabled:cursor-not-allowed; } +input, +select, +textarea, +button { + font-size: var(--font-size); + line-height: var(--line-height); +} + .input[type="file"], .input[type="radio"], #installPWA { diff --git a/assets/scss/themes.scss b/assets/scss/themes.scss index 80cf3a87f..ad1c86e8c 100644 --- a/assets/scss/themes.scss +++ b/assets/scss/themes.scss @@ -297,3 +297,36 @@ :root[data-accent="yellow"] { @include yellowTheme; } + +@mixin fontSmall { + // Font size + --font-size: 0.75rem; + // Line height + --line-height: 1rem; +} + +@mixin fontMedium { + // Font size + --font-size: 0.875rem; + // Line height + --line-height: 1.25rem; +} + +@mixin fontLarge { + // Font size + --font-size: 1rem; + // Line height + --line-height: 1.5rem; +} + +:root[data-font-size="xs"] { + @include fontSmall; +} + +:root[data-font-size="sm"] { + @include fontMedium; +} + +:root[data-font-size="base"] { + @include fontLarge; +} diff --git a/components/smart/AccentModePicker.vue b/components/smart/AccentModePicker.vue index d85970afe..dfc326179 100644 --- a/components/smart/AccentModePicker.vue +++ b/components/smart/AccentModePicker.vue @@ -47,7 +47,6 @@ export default Vue.extend({ methods: { setActiveColor(color: HoppAccentColor) { document.documentElement.setAttribute("data-accent", color) - applySetting("THEME_COLOR", color) }, }, diff --git a/components/smart/ChangeLanguage.vue b/components/smart/ChangeLanguage.vue index cc4ca39f0..c3de9077d 100644 --- a/components/smart/ChangeLanguage.vue +++ b/components/smart/ChangeLanguage.vue @@ -1,35 +1,36 @@ diff --git a/components/smart/FontSizePicker.vue b/components/smart/FontSizePicker.vue new file mode 100644 index 000000000..031e23a6b --- /dev/null +++ b/components/smart/FontSizePicker.vue @@ -0,0 +1,68 @@ + + + diff --git a/components/smart/Item.vue b/components/smart/Item.vue index 1489ff6a9..90304af0b 100644 --- a/components/smart/Item.vue +++ b/components/smart/Item.vue @@ -6,15 +6,13 @@ class=" rounded font-semibold - text-xs py-2 px-4 transition inline-flex items-center - focus:bg-primaryDark focus:text-secondaryDark hover:bg-primaryDark hover:text-secondaryDark - focus:outline-none + focus:bg-primaryDark focus:outline-none focus:text-secondaryDark " :class="[ { 'opacity-75 cursor-not-allowed': disabled }, diff --git a/lang/en-US.json b/lang/en-US.json index 3d54cdcf9..ca1329fce 100644 --- a/lang/en-US.json +++ b/lang/en-US.json @@ -152,7 +152,12 @@ "shortcuts_indicator": "Shortcuts indicator", "telemetry": "Telemetry", "interceptor": "Interceptor", - "navigation_sidebar": "Navigation sidebar" + "navigation_sidebar": "Navigation sidebar", + "font_size": "Font size", + "change_font_size": "Change font size", + "language": "Language", + "choose_language": "Choose language", + "accent_color": "Accent color" }, "layout": { "zen_mode": "Zen mode" @@ -166,7 +171,6 @@ "endpoint": "Endpoint", "schema": "Schema", "theme": "Theme", - "choose_language": "Choose Language", "shortcuts": "Shortcuts", "javascript_code": "JavaScript Code", "method": "Method", @@ -217,7 +221,6 @@ "types": "Types", "send": "Send", "background": "Background", - "color": "Color", "labels": "Labels", "enabled": "Enabled", "disabled": "Disabled", diff --git a/layouts/default.vue b/layouts/default.vue index 65097e258..3445c7ea1 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -77,6 +77,10 @@ export default defineComponent({ this.$subscribeTo(getSettingSubject("BG_COLOR"), (color) => { ;(this as any).$colorMode.preference = color }) + + this.$subscribeTo(getSettingSubject("FONT_SIZE"), (size) => { + document.documentElement.setAttribute("data-font-size", size.code) + }) }, async mounted() { performMigrations() diff --git a/layouts/error.vue b/layouts/error.vue index 6658beeff..2016c4e30 100644 --- a/layouts/error.vue +++ b/layouts/error.vue @@ -1,7 +1,7 @@