Skip to content

Commit

Permalink
add md3 segment button component
Browse files Browse the repository at this point in the history
  • Loading branch information
NyaomiDEV committed Jul 31, 2024
1 parent 7f523fb commit 4063310
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 32 deletions.
22 changes: 22 additions & 0 deletions src/components/MD3SegmentButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<script setup lang="ts">
import { IonSegmentButton, IonIcon } from "@ionic/vue";
import CheckMD from '@material-design-icons/svg/outlined/check.svg';
</script>

<template>
<IonSegmentButton layout="icon-start">
<IonIcon :md="CheckMD" aria-hidden="true"/>
<slot></slot>
</IonSegmentButton>
</template>

<style scoped>
ion-icon {
display: none;
}
ion-segment-button.md.segment-button-checked ion-icon {
display: inline;
}
</style>
10 changes: 5 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ import "./styles/override.css";
import { activateMaterialTheme, updateMaterialColors } from "./lib/theme";
import "./lib/theme/style.css";

// Config
import { getConfigEntry } from "./lib/config";
import { AccessibilityConfig } from "./lib/config/types";

if(!window.isSecureContext){
console.error("Cannot continue, this is not a safe environment!");
document.documentElement.classList.add("hydrated");
Expand All @@ -70,7 +66,11 @@ if(!window.isSecureContext){
updateAccessibility();

const app = createApp(App).use(IonicVue).use(router).use(I18NextVue, { i18next: i18n });

app.mount(document.body);

await router.isReady();
console.log(router.currentRoute.value)
if(router.currentRoute.value.fullPath === "/")
router.push("/members");
}

12 changes: 6 additions & 6 deletions src/modals/TagEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
IonItem,
modalController,
IonModal,
IonSegment,
IonSegmentButton
IonSegment
} from "@ionic/vue";
import MD3SegmentButton from "../components/MD3SegmentButton.vue";
import Color from "../components/Color.vue";
import {
Expand Down Expand Up @@ -103,16 +103,16 @@
<IonLabel>
<h3 class="centered-text">{{ $t("options:tagManagement.edit.type.header") }}</h3>
<IonSegment class="segment-alt" v-model="tag!.type">
<IonSegmentButton value="member">
<MD3SegmentButton value="member">
<IonLabel>
{{ $t("options:tagManagement.edit.type.member") }}
</IonLabel>
</IonSegmentButton>
<IonSegmentButton value="journal">
</MD3SegmentButton>
<MD3SegmentButton value="journal">
<IonLabel>
{{ $t("options:tagManagement.edit.type.journal") }}
</IonLabel>
</IonSegmentButton>
</MD3SegmentButton>
</IonSegment>
<p class="centered-text">{{ $t("options:tagManagement.edit.type.desc") }}</p>
</IonLabel>
Expand Down
4 changes: 0 additions & 4 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ const routes: Array<RouteRecordRaw> = [
name: "TabbedHomeView",
component: () => import("../views/TabbedHomeView.vue"),
children: [
{
path: "/",
redirect: "/dashboard"
},
...tabbedRoutes
]
},
Expand Down
29 changes: 12 additions & 17 deletions src/views/options/Accessibility.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<script setup lang="ts">
import { IonContent, IonHeader, IonItem, IonIcon, IonRange, IonLabel, IonToggle, IonList, IonPage, IonTitle, IonToolbar, IonBackButton, IonSegment, IonSegmentButton} from '@ionic/vue';
import { IonContent, IonHeader, IonItem, IonRange, IonLabel, IonToggle, IonList, IonPage, IonTitle, IonToolbar, IonBackButton, IonSegment } from '@ionic/vue';
import { inject, reactive, watch } from 'vue';
import { AccessibilityConfig } from '../../lib/config/types';
import { getConfigEntry, saveConfig } from '../../lib/config';
import { updateAccessibility, updateDarkMode } from '../../lib/mode';
import Color from '../../components/Color.vue';
import { updateMaterialColors } from '../../lib/theme';
import CheckMD from '@material-design-icons/svg/outlined/check.svg';
import MD3SegmentButton from '../../components/MD3SegmentButton.vue';
const config = reactive(getConfigEntry("accessibility") as AccessibilityConfig);
watch(config, () => {
Expand Down Expand Up @@ -50,15 +50,13 @@
<h3 class="centered-text">{{ $t("options:accessibility.highLegibilityFontType.title") }}</h3>
<IonSegment class="segment-alt" value="high-legibility-type" v-model="config.highLegibilityType">

<IonSegmentButton value="atkinson" layout="icon-start">
<IonIcon v-if="config.highLegibilityType == 'atkinson'" :md="CheckMD" aria-hidden="true"/>
<MD3SegmentButton value="atkinson">
<IonLabel>{{ $t("options:accessibility.highLegibilityFontType.atkinson") }}</IonLabel>
</IonSegmentButton>
</MD3SegmentButton>

<IonSegmentButton value="opendyslexic" layout="icon-start">
<IonIcon v-if="config.highLegibilityType == 'opendyslexic'" :md="CheckMD" aria-hidden="true"/>
<MD3SegmentButton value="opendyslexic">
<IonLabel>{{ $t("options:accessibility.highLegibilityFontType.opendyslexic") }}</IonLabel>
</IonSegmentButton>
</MD3SegmentButton>
</IonSegment>
</IonLabel>
</IonItem>
Expand All @@ -68,20 +66,17 @@
<h3 class="centered-text">{{ $t("options:accessibility.uiVariant.title") }}</h3>
<IonSegment class="segment-alt" value="ui-variant" v-model="config.theme">

<IonSegmentButton value="auto" layout="icon-start">
<IonIcon v-if="config.theme == 'auto'" :md="CheckMD" aria-hidden="true"/>
<MD3SegmentButton value="auto">
<IonLabel>{{ $t("options:accessibility.uiVariant.auto") }}</IonLabel>
</IonSegmentButton>
</MD3SegmentButton>

<IonSegmentButton value="light" layout="icon-start">
<IonIcon v-if="config.theme == 'light'" :md="CheckMD" aria-hidden="true"/>
<MD3SegmentButton value="light">
<IonLabel>{{ $t("options:accessibility.uiVariant.light") }}</IonLabel>
</IonSegmentButton>
</MD3SegmentButton>

<IonSegmentButton value="dark" layout="icon-start">
<IonIcon v-if="config.theme == 'dark'" :md="CheckMD" aria-hidden="true"/>
<MD3SegmentButton value="dark">
<IonLabel>{{ $t("options:accessibility.uiVariant.dark") }}</IonLabel>
</IonSegmentButton>
</MD3SegmentButton>
</IonSegment>
</IonLabel>
</IonItem>
Expand Down

0 comments on commit 4063310

Please sign in to comment.