Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the codebase #86

Draft
wants to merge 57 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
e5b6fdf
📝 ORGANIZING_COMPONENTS: Adjust component tree
ewen-lbh May 6, 2020
0ba8c3f
♻️ Add new component files to match the goal component tree
ewen-lbh May 6, 2020
b127f58
🚚 Move old components to ~/components/legacy/
ewen-lbh May 17, 2020
ae1abd3
🚧 Create <BaseButton>, <BaseCard> and <ButtonPrimary>
ewen-lbh May 17, 2020
afac96e
🚧 <ButtonPrimary> Handle [dangerous] *and* [disabled]
ewen-lbh May 18, 2020
d37399c
🚚 Move legacy component tests
ewen-lbh May 18, 2020
6b7fc2f
💄 <ButtonPrimary> Add display: inline-block
ewen-lbh May 18, 2020
05f1f81
📝 CONTRIBUTING: Use HTML instead of pug
ewen-lbh May 18, 2020
9cd20ab
🚧 <BaseButton> Centralized [disabled], handle [href]
ewen-lbh May 18, 2020
5d46745
💄 material-icons: Convert font-size to `em`s
ewen-lbh May 18, 2020
99ca759
🚧 <ButtonSecondary> :active state
ewen-lbh May 18, 2020
4d060cd
♻️ <Button*> extend <BaseButton> instead of redeclaring props
ewen-lbh May 18, 2020
b85994c
♻️ Put potentially re-usable functions in utils/
ewen-lbh May 18, 2020
94adf16
🐛 validators: Change from ts to js
ewen-lbh May 18, 2020
bf0d554
🔧 Add typescript
ewen-lbh May 18, 2020
6eb4c3d
♻️ <ButtonIcon> Switch to TS
ewen-lbh May 19, 2020
051af02
💄 <ButtonIcon> Handle [small]
ewen-lbh May 19, 2020
e00b3da
✨ Create <SubjectBadge>
ewen-lbh May 19, 2020
e93d746
🏷️ <BaseButton> Switch to typescript
ewen-lbh May 19, 2020
458accb
✨ <BaseButton> Handle [href]
ewen-lbh May 19, 2020
f5b9cf7
💄 ^utils: Fix `lightColor` and `darkColor`, add `blackOrWhite`
ewen-lbh May 19, 2020
2202e93
🏷️ Add vue-shim.d.ts
ewen-lbh May 19, 2020
4f88421
🚧 ♻️ <TimeTable> Refactor from <Schedule>
ewen-lbh May 19, 2020
9c47380
🚚 Rename <SubjectBadge> to <BadgeSubject>
ewen-lbh May 19, 2020
560c78b
🔌 Create <TextLink>, remove link styling from global style rules
ewen-lbh May 21, 2020
0e19a64
🔌 Add `isIn` validator
ewen-lbh May 21, 2020
9753bd0
🔌 <TextLink> Handle internal & external links properly
ewen-lbh May 21, 2020
96edc76
🚧 Start creating <BaseInput>
ewen-lbh May 21, 2020
e7ce25c
📝 CONTRIBUTING: Add section about outer margins on components
ewen-lbh May 22, 2020
aedf9e4
Merge branch 'refactor-2020-05' of https://github.com/schoolsyst/fron…
ewen-lbh May 22, 2020
826c22b
🐛 <TextLink> Apply noopener, noreferrer to `isExternal`, not [new-tab]
ewen-lbh May 22, 2020
a1df55b
🔧 tsconfig: Temporarily disable libCheck
ewen-lbh May 22, 2020
914089e
🏷️ <TimeTable> Fix type errors
ewen-lbh May 22, 2020
e316274
💡 <TimeTable> Comment `methods.handleEventClick`
ewen-lbh May 22, 2020
b6682c8
🏷️ <TimeTable> Fix `handleHover`'s typing issue
ewen-lbh May 22, 2020
c49c598
⚗ Create /refactor-test
ewen-lbh May 22, 2020
914cb20
📝 CONTRIBUTING: Simpler structure for store action functions
ewen-lbh May 22, 2020
887ca10
🚨 eslint: Warn on camelcase, don't fail with an error
ewen-lbh May 22, 2020
8338c66
🏷️ Define types for homework, notes and quizzes
ewen-lbh May 22, 2020
d83f5a1
💄 <BadgeSubject> Make the dot smaller
ewen-lbh May 22, 2020
744a541
🚧 🔌 <BaseButton> Allow any URL
ewen-lbh May 22, 2020
898cbd0
🐛 <BaseCard> Make it an importable component, format code
ewen-lbh May 22, 2020
41ca65b
🐛 <Button*> Forward click events
ewen-lbh May 22, 2020
50aa87f
💄 <ButtonIcon> Remove side padding
ewen-lbh May 22, 2020
ac511a2
🐛 <TextLink> Remove URL validation
ewen-lbh May 22, 2020
532df24
🚧 Start making <CardHomework>
ewen-lbh May 22, 2020
32abcf3
🔧 tsconfig: exclude legacy components
ewen-lbh May 22, 2020
70a68e3
🔌 validators: Add `isUUID`
ewen-lbh May 22, 2020
bfc6247
🔀 origin/refactor-2020-05 into refactor-2020-05
ewen-lbh May 24, 2020
78b0ce7
♻️ Add <CardAdd>
ewen-lbh May 24, 2020
0b41c57
♻️ <BaseCard> Separate `border-color` from `border`
ewen-lbh May 24, 2020
a069240
♻️ <CardAdd> Detach from <BaseCard>
ewen-lbh May 24, 2020
0a255f3
🚧 Create heading components
ewen-lbh May 25, 2020
8cc2f1e
💄 <BaseInput> Add styling, allow more [element]s
ewen-lbh May 27, 2020
8ff5cdf
🔌 Create <InputText>
ewen-lbh May 27, 2020
7a5a1a2
💄 <ButtonPrimary> Make [small] version less tall
ewen-lbh May 27, 2020
a3a3992
🚧 🏷️ Started typing & reworking the store
ewen-lbh May 27, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ module.exports = {
browser: true,
node: true
},
parserOptions: {
parser: 'babel-eslint'
},
extends: [
'@nuxtjs',
'@nuxtjs/eslint-config-typescript',
'prettier',
'prettier/vue',
'plugin:prettier/recommended',
Expand All @@ -19,6 +16,8 @@ module.exports = {
],
// add your custom rules here
rules: {
"no-console": 0
'no-console': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'camelcase': 'warn'
}
}
78 changes: 30 additions & 48 deletions CONTRIBUTING.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Additionally, prefix component names with the following:
| UI Component that are made for user data input
|===

### No outer margins on components

Components should not include any king of spacing on the component's root element: components and pages that includes a component should be responsible for its spacing relative to the other elements included.

### Inheritance

[%header, cols=2*]
Expand Down Expand Up @@ -81,24 +85,23 @@ For each mutation, when the API request fails, handle the error by showing the u

Each mutation should return...

When the action succeeded ::
`[true, object, null]` with `object` the value returned by the matching mutation, or the inner action's `object` return value.
When the action succeededs ::
`{ data: object, error: null]` with `object` the value returned by the matching mutation, or the inner action's `object` return value.

When the action fails because of a validation error ::
`[false, validation, 'validation']` with `validation` the value returned by the `validate` getter, or by the inner action's `validation` return value
`{ data: validation, error: 'validation'}` with `validation` the value returned by the `validate` getter, or by the inner action's `validation` return value

When the action fails because of a network error ::
`[false, error, 'network']` with `error` the error object from the `try`/`catch` block.
`{ data: error, error: 'network'}` with `error` the error object from the `try`/`catch` block.

More generally, the return value is an array with:
More generally, the return value is an object with:

1. whether the action succeeded or not
2. the object/array that results from the underlying mutation
3. the failure level, if any. If it succeeded, this is `null`.
1. the object/array that results from the underlying mutation
2. the failure level, if any. If it succeeded, this is `null`.

Include the following actions:

load({ force: false, verbose: true }) ::
load({ force: false, verbose: false }) ::
- If `loaded` is false or `force` is true
** Do a `GET` request
** Use the `SET` mutation to store the response in the store
Expand Down Expand Up @@ -163,32 +166,10 @@ order(objects, { by: '_your_default_sorting_method_' }) ::
## Code clarity guidelines
### In vue files' <template>

Language :: pug
Language :: html
Indentation :: 2 spaces

#### Attribute shorthands order

_In single-line component uses_:
Put the class shorthand .class _after_ an attribute list and the #id shortand _before_:

```pug
ComponentName#id(attr="value").class.class2
```

_In multiline uses (eg. the attributes list is split on multiple lines)_:
Put all of the shorthands _before_ the attribute list

```pug
component#id.class.class2(
:is="componentName"
:style="styles"
:class="{clickable, multiline, thin, inline}"
:data-variant="variant"
type="button"
@click="$emit('click')"
v-tooltip="tooltipContent"
)
```
write component tag names in :: kebab-case
Class for root element of every component :: .--<component-kebab-case>; eg. for <BaseCard> root element has class=--base-card

#### Attribute list order

Expand Down Expand Up @@ -235,10 +216,10 @@ For object literals, don't add spaces around the braces (but do it in JS code)
For multi-values attributes (eg. `style` or `class`), prefer an object literal of computed values instead of a single computed value returning the entire object:

.`<template>`
```pug
component(
```html
<component
:style="{backgroundColor, color: subjectNameColor}"
)
>
```

.`<script>`
Expand All @@ -256,8 +237,8 @@ computed: {
Instead of:

.`<template>`
```pug
component(:style="styles")
```html
<component :style="styles">
```

.`<script>`
Expand All @@ -277,8 +258,8 @@ computed: {
In conditonnal directives, the value can be one of the above, or a logical-operator-separated list of variables, but there must be at most two operators.

.Example
```pug
template(v-if="loggedIn || passwordForgotten")
```html
<template v-if="loggedIn || passwordForgotten">
```

If the exact same condition is reused, make a computed property instead.
Expand All @@ -288,18 +269,19 @@ If the exact same condition is reused, make a computed property instead.
If the element contains more than two attributes:

.Bad example
```pug
template(v-if="thing" my-stuff :thingie="foo" bar="baz" quux)
```html
<template v-if="thing" my-stuff :thingie="foo" bar="baz" quux>
```

.Good example
```pug
template(
```html
<template
v-if="thing"
:thingie="foo"
bar="baz"
my-stuff quux
)
my-stuff
quux
>
```

### In vue _component_ file's <script>
Expand Down Expand Up @@ -363,7 +345,7 @@ Separate your styles into sections using the following comment decorations (incl

```

Include the following sections (even if empty, except for Hack), in order:
Include the following sections, in order:

. Definitions +
_Includes stylus variables & functions as well as CSS variables_
Expand Down
30 changes: 11 additions & 19 deletions ORGANIZING_COMPONENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

Components should be stateless: this makes them easier to debug & test. Appart from utility getters defined in `store/index.js`, no component should import state/getters/actions or mutations (mutations shouldn't be called anywhere except inside actions, by the way.)

Only the pages/layouts are responsible for state CRUD operations. Data should be passed by props to components via `v-bind`, or `v-model` when using inputs,


Only the pages/layouts are responsible for state CRUD operations. Data should be passed by props to components via `v-bind`, or `v-model` when using inputs,

## Legend

| What | it means |
| --------------- | ------------------------------------------ |
| *(Italic text)* | Notes |
| _Subcomponent_ | Component implemented as a "variant" prop. |
| 🚧 Component | To-Do component |
| 🗃 Component | Stateful components. |
| 🚧 Component | To-Do component |
| 🗃 Component | Stateful components. |
| ▶ Component | Components that takes inputs |

## The tree
Expand All @@ -37,13 +35,9 @@ Only the pages/layouts are responsible for state CRUD operations. Data should be
- ▶ Inputs

- Text input

- passwords

- date

- due date (smart)

- due date (smart)
- plain text

- *block variant (textarea)*
Expand All @@ -68,7 +62,7 @@ Only the pages/layouts are responsible for state CRUD operations. Data should be

- Links

- inline link
- _inline link_

- State screens

Expand Down Expand Up @@ -130,24 +124,22 @@ Only the pages/layouts are responsible for state CRUD operations. Data should be

- mutation

- ▶ Pickers
- ▶ Pickers _"Modal" not in component names for brevity_

- 🗃 subject _(Only use when using the dropdown is not possible)_

- color

- dialogs
- dialogs _"Modal" not in component names for brevity_

- confirm (w/ challenge)

- context menu

- Subject

- Badge

- Dot

- Badges
- Subject
- _dot_
- _badge_
- Schedule

- Unique components (prefixed with "The") _(This is not a base component)_
Expand Down
34 changes: 5 additions & 29 deletions assets/defaults.sass
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ body
// Greys
--black: #111111
--white: #ffffff
--grey-light: #c0c0c0
--grey: #d4d3d3
--grey-light: #d4d3d3
--grey: #c0c0c0
--grey-dark: #757575
--grey-offset: #F3F3F3
--grey-offset-dark: #e6e6e6
Expand All @@ -52,7 +52,8 @@ body
--red: #D50000
--red-light: #ff3519
--red-dark: #940000
--red-offset: #FF9E9E
--red-offset: #ffdddd
--red-offset-dark: #ffc3c3
// Greens
--green: #27CE5F
--green-light: #86e6b1
Expand All @@ -78,7 +79,7 @@ body
--blue-light: #89c4fe
--blue-dark: #006BD4
--blue-offset: #0b123a
--blue-offset-dark: #0d143a
--blue-offset-dark: #060b2b
// Reds
--red: #ee4949
--red-light: #ff604b
Expand Down Expand Up @@ -282,31 +283,6 @@ $bk-sidebar: 650px
border-bottom-left-radius: 0
border-bottom-right-radius: 0


//=====================
// LINKS
//=====================

p, pre
font-family: var(--fonts-normal)
a:not([no-default])
color: var(--blue)
border-bottom: 2px solid var(--blue)
&:hover,
&:focus,
&:active
color: var(--blue-dark)
border-color: var(--blue-dark)


p a[target=_blank]:not([no-external-link-indicator])::after
font-family: 'Material Icons'
content: '\e89e'
font-size: 1.2em
margin-left: 0.1em
position: relative
bottom: -.1em

//=====================
// LOADING SCREEN
//=====================
Expand Down
4 changes: 2 additions & 2 deletions assets/fonts/Material-Icons/import.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px;
font-size: 1.5em;
line-height: 1;
letter-spacing: normal;
text-transform: none;
Expand All @@ -33,7 +33,7 @@
font-family: 'Material Icons Outlined';
font-weight: normal;
font-style: normal;
font-size: 24px;
font-size: 1.5em;
line-height: 1;
letter-spacing: normal;
text-transform: none;
Expand Down
Loading