Skip to content

Commit

Permalink
✨ styled html dialog component
Browse files Browse the repository at this point in the history
  • Loading branch information
haliphax committed Nov 12, 2024
1 parent efcd12b commit c9edcba
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"tab",
{
"ignoredNodes": ["PropertyDefinition"],
"offsetTernaryExpressions": true
"offsetTernaryExpressions": true,
"SwitchCase": 1
}
],
"vue/multi-word-component-names": "off"
Expand Down
3 changes: 3 additions & 0 deletions src/front-end/app/app.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<script lang="ts">
import { defineComponent } from "vue";
import DarkMode from "./components/darkmode.vue";
import Dialogs from "./components/dialogs.vue";
import { ROOT_URI } from "./constants";
const App = defineComponent({
components: {
DarkMode,
Dialogs,
},
async beforeCreate() {
document.cookie = [
Expand All @@ -21,6 +23,7 @@ export default App;
</script>

<template>
<Dialogs></Dialogs>
<a class="btn ⏩" href="#main">
<span aria-hidden="true">⏩</span>
Skip to main
Expand Down
2 changes: 1 addition & 1 deletion src/front-end/app/components/darkmode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const DarkMode = defineComponent({
created() {
this.bodyClass(this.enabled);
this.$store.subscribe((mutation) => {
const keys = Object.getOwnPropertyNames(mutation.payload);
const keys = Object.getOwnPropertyNames(mutation.payload ?? {});
if (mutation.type == "session" && keys.includes("settings"))
this.enabled = (mutation.payload as SessionState).settings.darkMode;
Expand Down
42 changes: 32 additions & 10 deletions src/front-end/app/views/home/profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,51 @@ const Profile = defineComponent({
(this.$refs.file as HTMLInputElement).click();
},
async loadFile() {
const files = (this.$refs.file as HTMLInputElement).files;
const input = this.$refs.file as HTMLInputElement;
const files = input.files;
if (!files || files.length === 0) return;
if (files.length > 1) return alert("Please select a single file");
if (files.length > 1) {
input.value = "";
await this.$store.dispatch("alert", {
text: "Please select a single file",
});
return;
}
const file = files[0];
if (!file.name.endsWith(".json"))
return alert("Please select a JSON file");
if (!file.name.endsWith(".json")) {
input.value = "";
await this.$store.dispatch("alert", {
text: "Please select a JSON file",
});
return;
}
try {
const session: SessionState = JSON.parse(await file.text());
const session: SessionState = JSON.parse(await file.text());
this.$store.commit("session", session);
this.name = session.name;
} catch (ex) {
await this.$store.dispatch("alert", { text: `Error: ${ex}` });
} finally {
input.value = "";
}
this.$store.commit("session", session);
this.name = session.name;
requestAnimationFrame(() => {
requestAnimationFrame(async () => {
this.upToDate = true;
alert("Profile imported successfully");
await this.$store.dispatch("alert", {
text: "Profile imported successfully",
});
});
},
submit() {
this.$store.commit("session", { name: this.name });
this.upToDate = true;
alert("Profile updated");
this.$store.dispatch("alert", { text: "Profile updated" });
},
},
});
Expand Down
20 changes: 14 additions & 6 deletions src/front-end/app/views/story/actions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,30 @@
import { defineComponent } from "vue";
const Actions = defineComponent({
async mounted() {
this.$store.subscribeAction(async (a) => {
if (!(a.type === "confirmed" && a.payload === "reveal")) {
return;
}
console.log("Revealing story");
await this.$store.dispatch("story.reveal");
});
},
methods: {
async copyUrl() {
await window.navigator.clipboard.writeText(window.location.href);
alert("The room URL has been copied to your clipboard!");
await this.$store.dispatch("alert", {
text: "The room URL has been copied to your clipboard!",
});
},
async reveal() {
const message =
this.$store.state.story.story?.owner === this.$store.state.session.id
? "Are you ready to reveal the votes?"
: "You are not the owner of this story. Are you sure?";
if (!confirm(message)) {
return;
}
await this.$store.dispatch("story.reveal");
await this.$store.dispatch("confirm", { id: "reveal", text: message });
},
},
});
Expand Down
4 changes: 4 additions & 0 deletions src/front-end/styles/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ summary {
display: none;
}

.fr {
float: right;
}

.r {
text-align: right;
}
Expand Down

0 comments on commit c9edcba

Please sign in to comment.