Utilise une version auto-hebergé des polices plutôt que celles du CDN font.google

See #606
pull/1181/head
Johan Girod 2020-11-02 17:07:03 +01:00
parent 51e69b7220
commit f738e64710
16 changed files with 86 additions and 40 deletions

View File

@ -64,11 +64,7 @@
content="<%= htmlWebpackPlugin.options.shareImage %>"
/>
<!-- data-helmet pour que React Helmet puisse écraser ce meta par défaut -->
<link
href="https://fonts.googleapis.com/css?family=Roboto:400,400i,600|Montserrat:400,600"
rel="stylesheet"
type="text/css"
/>
<link rel="manifest" href="/manifest.webmanifest" />
<title>
<%= htmlWebpackPlugin.options.title %>

View File

@ -131,6 +131,8 @@ async function fetchSimulators(dt) {
'/profession-liberale/auxiliaire-medical',
'/profession-liberale/sage-femme',
'/profession-liberale/chirugien-dentiste',
'/profession-liberale/avocat',
'/profession-liberale/expert-comptable',
'/économie-collaborative'
].includes(label)
)
@ -170,7 +172,10 @@ async function fetchSimulators(dt) {
'/profession-liberale',
'/chirugien-dentiste',
'/auxiliaire-medical',
'/sage-femme'
'/sage-femme',
'/medecin',
'/avocat',
'/expert-comptable'
].some(path => x.label.startsWith(path))
)

View File

@ -0,0 +1,43 @@
/* roboto-regular - latin */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: local('Roboto'), local('Roboto-Regular'),
url('./fonts/roboto-v20-latin-regular.woff2') format('woff2'),
/* Chrome 26+, Opera 23+, Firefox 39+ */
url('./fonts/roboto-v20-latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* roboto-italic - latin */
@font-face {
font-family: 'Roboto';
font-style: italic;
font-weight: 400;
src: local('Roboto Italic'), local('Roboto-Italic'),
url('./fonts/roboto-v20-latin-italic.woff2') format('woff2'),
/* Chrome 26+, Opera 23+, Firefox 39+ */
url('./fonts/roboto-v20-latin-italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* roboto-500 - latin */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: bold;
src: local('Roboto Medium'), local('Roboto-Medium'),
url('./fonts/roboto-v20-latin-500.woff2') format('woff2'),
/* Chrome 26+, Opera 23+, Firefox 39+ */
url('./fonts/roboto-v20-latin-500.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* montserrat-600 - latin */
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 600;
src: local('Montserrat SemiBold'), local('Montserrat-SemiBold'),
url('./fonts/montserrat-v15-latin-600.woff2') format('woff2'),
/* Chrome 26+, Opera 23+, Firefox 39+ */
url('./fonts/montserrat-v15-latin-600.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}

View File

@ -23,6 +23,7 @@ html {
font-size: 1em;
}
}
body {
font-weight: 400;
color: #040e19;
@ -120,7 +121,7 @@ a:not(:disabled):not(.button):not(.button-choice):hover {
strong,
b {
font-weight: 600;
font-weight: bold;
}
textarea {

View File

@ -3,6 +3,7 @@
@import './Card.css';
@import './Toggle.css';
@import './reset.css';
@import './Fonts.css';
:root {
--color: rgb(41, 117, 209);

View File

@ -77,23 +77,6 @@ module.exports = {
clientsClaim: true,
skipWaiting: true,
swDest: 'sw.js',
runtimeCaching: [
{
urlPattern: new RegExp(
'https://fonts.(?:googleapis|gstatic).com/(.*)'
),
handler: 'cacheFirst',
options: {
cacheName: 'google-fonts',
expiration: {
maxEntries: 5
},
cacheableResponse: {
statuses: [0, 200]
}
}
}
],
navigateFallback: '/fallback',
navigateFallbackWhitelist: [/^\/[^_]+$/], // fallback for anything that doesn't start with
navigateFallbackBlacklist: [

View File

@ -7,19 +7,17 @@ const evaluateRecalcul = (cache, situation, parsedRules, node) => {
return defaultNode(false)
}
const amendedSituation =
node.explanation.amendedSituation
.map(([originRule, replacement]) => [
evaluateNode(cache, situation, parsedRules, originRule),
evaluateNode(cache, situation, parsedRules, replacement)
])
.filter(
([originRule, replacement]) =>
originRule.nodeValue !== replacement.nodeValue ||
serializeUnit(originRule.unit) !== serializeUnit(replacement.unit)
)
const amendedSituation = node.explanation.amendedSituation
.map(([originRule, replacement]) => [
evaluateNode(cache, situation, parsedRules, originRule),
evaluateNode(cache, situation, parsedRules, replacement)
])
.filter(
([originRule, replacement]) =>
originRule.nodeValue !== replacement.nodeValue ||
serializeUnit(originRule.unit) !== serializeUnit(replacement.unit)
)
// Optimisation : no need for recalcul if situation is the same
const recalculCache = Object.keys(amendedSituation).length
? { _meta: { ...cache._meta, inRecalcul: true } } // Create an empty cache
@ -27,8 +25,14 @@ const evaluateRecalcul = (cache, situation, parsedRules, node) => {
const evaluatedNode = evaluateNode(
recalculCache,
{ ...situation,
...Object.fromEntries(amendedSituation.map(([originRule, replacement]) => [originRule.dottedName, replacement]))
{
...situation,
...Object.fromEntries(
amendedSituation.map(([originRule, replacement]) => [
originRule.dottedName,
replacement
])
)
},
parsedRules,
node.explanation.recalcul

View File

@ -65,6 +65,19 @@ module.exports.commonLoaders = ({ legacy = false, file = true } = {}) => {
}
]
: []),
{
test: /\.(ttf|woff2?)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts',
publicPath: '/fonts'
}
}
]
},
{
test: /\.yaml$/,
use: ['json-loader', 'yaml-loader']
@ -82,7 +95,7 @@ module.exports.commonLoaders = ({ legacy = false, file = true } = {}) => {
use: ['raw-loader']
},
{
test: /\.(ttf|pdf)$/,
test: /\.pdf$/,
use: ['file-loader']
}
]