diff --git a/public/assets/fonts/SF-Pro-Text-Regular.otf b/public/assets/fonts/SF-Pro-Text-Regular.otf new file mode 100755 index 0000000..06dbe85 Binary files /dev/null and b/public/assets/fonts/SF-Pro-Text-Regular.otf differ diff --git a/public/assets/forms.js b/public/assets/forms.js index f12c3eb..beb0c27 100644 --- a/public/assets/forms.js +++ b/public/assets/forms.js @@ -26,22 +26,20 @@ export const psychForm = { } +/* Dummy algo for demo purposes, simply takes average of fields. */ +export const psychAlgo = (form, res) => { - // algo: () => { + const vals = []; - // const values = []; + form.steps.forEach(s => { - // steps.forEach(s => { + s.fields.forEach(f => { - // s.fields.forEach(f => { + vals.push(f.value); - // values.push(f.value); + }); - // }); + }); - // }); - - // const sum = values.reduce((p, c) => p + c, 0); - - // return sum / values.length; - // } + res.value = Math.floor(vals.reduce((a, b) => a + b) / vals.length); +} diff --git a/public/components/form.js b/public/components/form.js index 7f46657..5269593 100644 --- a/public/components/form.js +++ b/public/components/form.js @@ -13,9 +13,16 @@ const Form = const curr = Vue.ref(0); function next() { - curr.value < props.steps.length - 1 ? - curr.value += 1 : + + console.log(props.steps); + + if (curr.value > props.steps.length - 2) { props.submit(); + return; + } + + curr.value += 1; + } return { curr, next }; @@ -26,20 +33,15 @@ const Form = - + ` } export default Form; - -/* - -So we store the results of the form inside the templete itself. - -Is this really a good idea? - -Why not just have a mapping that we fill out as the form progresses? - -*/ diff --git a/public/components/main.js b/public/components/main.js index 9c98143..8f6b6aa 100644 --- a/public/components/main.js +++ b/public/components/main.js @@ -1,9 +1,8 @@ -import { psychForm } from "../assets/forms.js"; +import { psychForm, psychAlgo } from "../assets/forms.js"; import Form from "./form.js"; import Range from "./range.js"; - const Main = { components: { @@ -12,6 +11,7 @@ const Main = setup() { + const res = Vue.ref(0); const state = Vue.ref(0); function showForm() { @@ -19,14 +19,15 @@ const Main = } function submit() { + psychAlgo(psychForm, res); /* pass by ref flex ;) */ state.value = 2; } - return { psychForm, state, showForm, submit }; + return { psychForm, state, showForm, submit, res }; }, template: ` -
+
@@ -40,17 +41,10 @@ const Main =
-
Result!
+
{{ res }}
` } export default Main; - -/* - -Notes... - -*/ - diff --git a/public/components/range.js b/public/components/range.js index e5dcd99..9bb8d17 100644 --- a/public/components/range.js +++ b/public/components/range.js @@ -8,28 +8,28 @@ const Range = setup(props) { - const value = Vue.ref(50); + const ref = Vue.ref(50); - Vue.watch(value, (c, _p) => { + Vue.watch(ref, (c, _p) => { - props.field.value = c; + props.field.value = parseInt(c); }); - return { value }; + return { ref }; }, template: ` -
+
- Range Input! +
{{ ref }}
diff --git a/public/components/result.js b/public/components/result.js deleted file mode 100644 index 8426a0f..0000000 --- a/public/components/result.js +++ /dev/null @@ -1,36 +0,0 @@ -const Result = -{ - props: ["form"], - - setup(props) - { - return { }; - }, - - template: ` -
- - Result! - -
- ` -} - -export default Result; - - - - -/* - -Takes in data from the form and displays it. - -Of course, all forms will have a different algo to process their data. - -So each form can supply it's own algo. - -But algos are required to return an int. - -So the results page can render that int in it's own way. - -*/ diff --git a/public/components/step.js b/public/components/step.js index 775177f..4f0979c 100644 --- a/public/components/step.js +++ b/public/components/step.js @@ -18,24 +18,10 @@ const Step =
{{ prompt }}
-
- - - -
+
` } export default Step; - -/* - -Single step of the form, can have multiple fields. - -There is only one type of field (range), but could be more. - -Were gonna pass in the data object to the field. - -*/ \ No newline at end of file diff --git a/public/main.css b/public/main.css index 6c0f505..2a2b0da 100644 --- a/public/main.css +++ b/public/main.css @@ -1,3 +1,8 @@ +@font-face { + font-family: "Default"; + src: url("assets/fonts/SF-Pro-Text-Regular.otf"); +} + @font-face { font-family: "Rounded"; src: url("assets/fonts/SF-Compact-Rounded-Bold.otf"); @@ -7,6 +12,7 @@ html, body { margin: 0; padding: 0; background-color: #EBEBEB; + font-family: "Default"; } #main { @@ -18,9 +24,8 @@ html, body { } .form { - width: 50vw; - height: 50vh; - background-color: white; + width: 100%; + height: 100%; position: relative; } @@ -30,26 +35,32 @@ html, body { display: flex; justify-content: center; align-items: center; - background-color: lightgray; } .prompt { top: 0; left: 0; position: absolute; + padding: 20px; } -.fields { +.range { + font-family: "Rounded"; +} + +.result { + font-size: 60px; + font-family: "Rounded"; } .button { border: none; outline: none; text-decoration: none; + font-family: "Rounded"; } .next-button { - font-family: "Rounded"; background-color: #B7B7B7; padding: 10px 20px; border-radius: 20px; @@ -61,7 +72,8 @@ html, body { } .form-button { - position: absolute; bottom: 0; right: 0; + position: absolute; + margin: 20px; } \ No newline at end of file