Skip to content

Commit e05be5d

Browse files
authored
Merge pull request #52 from SourceCodeOER/tutoriel
feat: add tutoriel section
2 parents 5fd7c52 + d4af3a0 commit e05be5d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1384
-17
lines changed

app/router.scrollBehavior.js

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<% if (router.scrollBehavior) { %>
2+
<%= isTest ? '/* eslint-disable quotes, semi, indent, comma-spacing, key-spacing, object-curly-spacing, space-before-function-paren */' : '' %>
3+
export default <%= serializeFunction(router.scrollBehavior) %>
4+
<%= isTest ? '/* eslint-enable quotes, semi, indent, comma-spacing, key-spacing, object-curly-spacing, space-before-function-paren */' : '' %>
5+
<% } else { %>import { getMatchedComponents } from './utils'
6+
7+
if (process.client) {
8+
if ('scrollRestoration' in window.history) {
9+
window.history.scrollRestoration = 'manual'
10+
11+
// reset scrollRestoration to auto when leaving page, allowing page reload
12+
// and back-navigation from other pages to use the browser to restore the
13+
// scrolling position.
14+
window.addEventListener('beforeunload', () => {
15+
window.history.scrollRestoration = 'auto'
16+
})
17+
18+
// Setting scrollRestoration to manual again when returning to this page.
19+
window.addEventListener('load', () => {
20+
window.history.scrollRestoration = 'manual'
21+
})
22+
}
23+
}
24+
25+
export default function (to, from, savedPosition) {
26+
// if the returned position is falsy or an empty object,
27+
// will retain current scroll position.
28+
let position = false
29+
30+
// if no children detected and scrollToTop is not explicitly disabled
31+
const Pages = getMatchedComponents(to)
32+
if (
33+
Pages.length < 2 &&
34+
Pages.every(Page => Page.options.scrollToTop !== false)
35+
) {
36+
// scroll to the top of the page
37+
position = { x: 0, y: 0 }
38+
} else if (Pages.some(Page => Page.options.scrollToTop)) {
39+
// if one of the children has scrollToTop option set to true
40+
position = { x: 0, y: 0 }
41+
}
42+
43+
// savedPosition is only available for popstate navigations (back button)
44+
if (savedPosition) {
45+
position = savedPosition
46+
}
47+
48+
const nuxt = window.<%= globals.nuxt %>
49+
50+
// triggerScroll is only fired when a new component is loaded
51+
if (to.path === from.path && to.hash !== from.hash) {
52+
nuxt.$nextTick(() => nuxt.$emit('triggerScroll'))
53+
}
54+
55+
return new Promise((resolve) => {
56+
// wait for the out transition to complete (if necessary)
57+
nuxt.$once('triggerScroll', () => {
58+
// coords will be used if no selector is provided,
59+
// or if the selector didn't match any element.
60+
if (to.hash) {
61+
let hash = to.hash
62+
// CSS.escape() is not supported with IE and Edge.
63+
if (typeof window.CSS !== 'undefined' && typeof window.CSS.escape !== 'undefined') {
64+
hash = '#' + window.CSS.escape(hash.substr(1))
65+
}
66+
try {
67+
if (document.querySelector(hash)) {
68+
// scroll to anchor by returning the selector
69+
position = { selector: hash, offset: {x:0, y: 100} }
70+
}
71+
} catch (e) {
72+
<%= isTest ? '// eslint-disable-next-line no-console' : '' %>
73+
console.warn('Failed to save scroll position. Please add CSS.escape() polyfill (https://github.com/mathiasbynens/CSS.escape).')
74+
}
75+
}
76+
resolve(position)
77+
})
78+
})
79+
}
80+
<% } %>

assets/css/_markdown-style.scss

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@
1111
font-size: 1.3em;
1212
}
1313

14+
h2 {
15+
margin-bottom: 10px;
16+
margin-top: 30px;
17+
18+
~ h3 {
19+
margin-top: 20px;
20+
}
21+
}
22+
23+
24+
h3 {
25+
font-size: .975em;
26+
}
27+
1428
img {
1529
margin-top: 20px;
1630
margin-bottom: 20px;
@@ -96,7 +110,11 @@
96110
}
97111

98112
a {
99-
color: $NIGHT_BLUE
113+
color: $NIGHT_BLUE;
114+
115+
&.external-link {
116+
color: $TERNARY_COLOR
117+
}
100118
}
101119

102120
blockquote {

components/Editor/RichTextEditor.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@
124124

125125
<div class="menubar__button__wrapper">
126126

127+
<button
128+
class="menubar__button menubar__button--with-icon"
129+
:class="{ 'button--grey-light-reverse': isActive.code_block(), 'button--grey-light': !isActive.code_block() }"
130+
@click="commands.code_block"
131+
title="Bloc de code"
132+
>
133+
<Icon type="codeBlock" :theme="isActive.code_block() ? 'theme--white' : 'theme--grey-light'"/>
134+
</button>
127135

128136
<button
129137
class="menubar__button menubar__button--with-icon"
@@ -134,14 +142,6 @@
134142
<Icon type="codeBasic" :theme="isActive.code() ? 'theme--white' : 'theme--grey-light'"/>
135143
</button>
136144

137-
<button
138-
class="menubar__button menubar__button--with-icon"
139-
:class="{ 'button--grey-light-reverse': isActive.code_block(), 'button--grey-light': !isActive.code_block() }"
140-
@click="commands.code_block"
141-
title="Bloc de code"
142-
>
143-
<Icon type="codeBlock" :theme="isActive.code_block() ? 'theme--white' : 'theme--grey-light'"/>
144-
</button>
145145

146146
</div>
147147

components/Menu.vue

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,31 @@
3535
</div>
3636
Bibliothèque
3737
</nuxt-link>
38+
39+
<nuxt-link class="cta-link cta-link-with-arrow" tag="li" :class="isTutorialLink" to="/tutoriel/introduction">
40+
<div class="logo-link-wrapper">
41+
<Icon type="info" theme="theme--white"/>
42+
</div>
43+
Tutoriel
44+
</nuxt-link>
3845
</ul>
3946

4047
<template v-if="isAuthenticated && (role === 'admin' || role === 'super_admin')">
4148
<span>Administration</span>
4249
<ul>
43-
<nuxt-link class="cta-link cta-link-with-arrow" tag="li" to="/administration/exercices">
50+
<nuxt-link class="cta-link cta-link-with-arrow" tag="li" :class="isAdministrationExerciseLink" to="/administration/exercices">
4451
<div class="logo-link-wrapper">
4552
<Icon type="document" theme="theme--white"/>
4653
</div>
4754
Exercices
4855
</nuxt-link>
49-
<nuxt-link class="cta-link cta-link-with-arrow" tag="li" to="/administration/categories">
56+
<nuxt-link class="cta-link cta-link-with-arrow" tag="li" :class="isAdministrationCategoryLink" to="/administration/categories">
5057
<div class="logo-link-wrapper">
5158
<Icon type="bookmark" theme="theme--white"/>
5259
</div>
5360
Catégories
5461
</nuxt-link>
55-
<nuxt-link class="cta-link cta-link-with-arrow" tag="li" to="/administration/tags">
62+
<nuxt-link class="cta-link cta-link-with-arrow" tag="li" :class="isAdministrationTagLink" to="/administration/tags">
5663
<div class="logo-link-wrapper">
5764
<Icon type="tags" theme="theme--white"/>
5865
</div>
@@ -70,13 +77,13 @@
7077
<template v-if="isAuthenticated">
7178
<span>Gestion</span>
7279
<ul>
73-
<nuxt-link class="cta-link cta-link-with-arrow" tag="li" to="/gestion/mes-exercices">
80+
<nuxt-link class="cta-link cta-link-with-arrow" :class="isGestionLink" tag="li" to="/gestion/mes-exercices">
7481
<div class="logo-link-wrapper">
7582
<Icon type="document" theme="theme--white"/>
7683
</div>
7784
Mes exercices
7885
</nuxt-link>
79-
<nuxt-link class="cta-link cta-link-with-arrow" tag="li" to="/gestion/mes-favoris">
86+
<nuxt-link class="cta-link cta-link-with-arrow" :class="isFavoriteLink" tag="li" to="/gestion/mes-favoris">
8087
<div class="logo-link-wrapper">
8188
<Icon type="star" theme="theme--white"/>
8289
</div>
@@ -138,6 +145,42 @@
138145
return this.$auth.user.role
139146
}
140147
148+
get isAdministrationExerciseLink() {
149+
const regex = new RegExp(/^(\/administration\/exercices)/gm);
150+
if(this.$route.path.match(regex)) return 'nuxt-link-exact-active';
151+
return '';
152+
}
153+
154+
get isAdministrationTagLink() {
155+
const regex = new RegExp(/^(\/administration\/tags)/gm);
156+
if(this.$route.path.match(regex)) return 'nuxt-link-exact-active';
157+
return '';
158+
}
159+
160+
get isAdministrationCategoryLink() {
161+
const regex = new RegExp(/^(\/administration\/categories)/gm);
162+
if(this.$route.path.match(regex)) return 'nuxt-link-exact-active';
163+
return '';
164+
}
165+
166+
get isGestionLink() {
167+
const regex = new RegExp(/^(\/gestion\/mes-exercices)/gm);
168+
if(this.$route.path.match(regex)) return 'nuxt-link-exact-active';
169+
return '';
170+
}
171+
172+
get isFavoriteLink() {
173+
const regex = new RegExp(/^(\/gestion\/mes-favoris)/gm);
174+
if(this.$route.path.match(regex)) return 'nuxt-link-exact-active';
175+
return '';
176+
}
177+
178+
get isTutorialLink() {
179+
const regex = new RegExp(/^(\/tutoriel)/gm);
180+
if(this.$route.path.match(regex)) return 'nuxt-link-exact-active';
181+
return '';
182+
}
183+
141184
async logout() {
142185
this.$accessor.favorites.RESET();
143186
this.$accessor.historical.RESET();

components/Panel/Item/FavoritePanel.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@
130130
searchRequest.data = searchCriterion;
131131
132132
await this.$accessor.exercises.fetch(searchRequest);
133+
134+
this.$emit('fetch');
133135
}
134136
}
135137
</script>

components/Symbols/Icon.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
bookmark: () => import('./library/BookmarkSymbol.vue'),
4343
mail: () => import('./library/MailSymbol.vue'),
4444
clock: () => import('./library/ClockSymbol.vue'),
45+
info: () => import('./library/InfoSymbol.vue'),
4546
book: () => import('./library/BookSymbol.vue')
4647
}
4748
})
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<template>
2+
<svg xmlns='http://www.w3.org/2000/svg' width='512' height='512' viewBox='0 0 512 512'><path :class="themeStroke" d='M248,64C146.39,64,64,146.39,64,248s82.39,184,184,184,184-82.39,184-184S349.61,64,248,64Z' style='fill:none;stroke-miterlimit:10;stroke-width:32px'/><polyline :class="themeStroke" points='220 220 252 220 252 336' style='fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px'/><line :class="themeStroke" x1='208' y1='340' x2='296' y2='340' style='fill:none;stroke-linecap:round;stroke-miterlimit:10;stroke-width:32px'/><path :class="theme" d='M248,130a26,26,0,1,0,26,26A26,26,0,0,0,248,130Z'/></svg>
3+
</template>
4+
5+
<script lang="ts">
6+
import Symbol from "../Symbol.vue";
7+
import {Component, Mixins} from 'vue-property-decorator'
8+
9+
@Component
10+
export default class InfoSymbol extends Mixins(Symbol) {}
11+
</script>

0 commit comments

Comments
 (0)