Skip to content

Commit 522efc5

Browse files
authored
Merge pull request #526 from BeAPI/feat/migrate-theme-json
feat(typography): migration typo vers theme.json
2 parents 7361990 + f3aea0f commit 522efc5

17 files changed

Lines changed: 260 additions & 154 deletions

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# 5.5.1
2+
3+
- Typographie du socle dans les fragments `theme.json` (`fontSizes` fluid Gutenberg, `fontFamilies` + `fontFace`, `custom.lineHeight`)
4+
- Polices locales variable woff2 (latin) : Source Sans 3 / Fraunces à la place de Poppins / `@fontsource`
5+
- Mixins `heading` / `text` branchés sur les tokens SCSS générés (`$settings-font-size-*`, `$settings-font-family-*`, `$settings-custom-line-height-*`)
6+
- Suppression de l’échelle `--heading--*` / `--paragraph--*` dans `_variables-css.scss` sur ce socle
7+
- Les projets BFF antérieurs à `5.5.1` conservent leur pipeline typo SCSS ; ne pas migrer automatiquement
8+
19
# 5.5.0
210

311
- Ajout du réglage `is_lcp` à `get_the_image()` (`fetchpriority` élevé, pas de lazy loading ; `decoding` en opt-in via les attributs)

‎README.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ Les fichiers de configuration se trouvent dans le dossier `config`.
160160
Vous trouverez le fichier de paramètres Webpack communs dans `webpack.common.js`. Pour le mode développement, éditez `webpack.dev.js` ; pour la production, `webpack.prod.js`.
161161
Les loaders sont dans `loaders.js` et les plugins Webpack dans `plugins.js`.
162162

163+
### Typographie (`theme.json`)
164+
165+
À partir de **BFF 5.5.1**, l’échelle typographique du socle (tailles fluid, familles, `fontFace`, line-heights) vit dans `src/theme-json/` (notamment `typography.json`). Le build régénère `theme.json` et `src/scss/01-abstract/_theme-json.scss` ; les mixins SCSS consomment les variables `$settings-*` générées.
166+
167+
Ne pas éditer à la main les fichiers générés. Sur un projet issu d’un BFF antérieur à **5.5.1** qui garde encore la typo en SCSS / propriétés CSS custom, conserver ce pipeline — ne pas migrer vers les fragments typo uniquement parce que le socle upstream a changé.
168+
163169
## Comment utiliser BFF ?
164170

165171
Après l’installation des dépendances, vous pouvez exécuter les commandes décrites ci-dessous.

‎config/webpack-theme-json-plugin.js‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,31 @@ class WebpackThemeJsonPlugin {
122122

123123
return result
124124
},
125+
'settings-typography-fontSizes'(key, value) {
126+
let result = ''
127+
128+
for (const fontSize of value) {
129+
const cssSlug = toPresetCssSlug(fontSize.slug)
130+
result += `${getVariableName(
131+
'settings-font-size-' + fontSize.slug
132+
)}: var(--wp--preset--font-size--${cssSlug});\n`
133+
}
134+
135+
return result
136+
},
137+
'settings-typography-fontFamilies'(key, value) {
138+
let result = ''
139+
const families = []
140+
141+
for (const family of value) {
142+
result += `${getVariableName('settings-font-family-' + family.slug)}: var(--wp--preset--font-family--${
143+
family.slug
144+
});\n`
145+
families.push(`${formatMapKey(family.slug)}: ${getVariableName('settings-font-family-' + family.slug)}`)
146+
}
147+
148+
return result + `$settings-font-families: (\n\t${families.join(',\n\t')}\n);\n`
149+
},
125150
}
126151
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
127152
const taskNames = Object.keys(tasks)
@@ -141,6 +166,11 @@ class WebpackThemeJsonPlugin {
141166
return `$${id.replace(/([A-Z])/g, '-$1').toLowerCase()}`
142167
}
143168

169+
// Match WordPress preset CSS custom property segments (e.g. h1 -> h-1).
170+
function toPresetCssSlug(slug) {
171+
return String(slug).replace(/([a-zA-Z])(\d)/g, '$1-$2')
172+
}
173+
144174
// Quote map keys so slugs like black/white are strings, not Sass color literals.
145175
function formatMapKey(slug) {
146176
return JSON.stringify(String(slug))

‎package-lock.json‎

Lines changed: 2 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "beapi-frontend-framework",
3-
"version": "5.5.0",
3+
"version": "5.5.1",
44
"author": "Be API",
55
"repository": {
66
"type": "git",
@@ -16,8 +16,6 @@
1616
},
1717
"license": "GPL-2.0",
1818
"dependencies": {
19-
"@fontsource-utils/scss": "^0.2.4",
20-
"@fontsource/poppins": "^5.3.0",
2119
"lazysizes": "^5.3.2",
2220
"oneloop.js": "^5.3.1",
2321
"swiper": "^14.3.0"
@@ -27,8 +25,8 @@
2725
"@wordpress/browserslist-config": "^6.53.0",
2826
"@wordpress/dependency-extraction-webpack-plugin": "^6.53.0",
2927
"@wordpress/dom-ready": "^3.58.0",
30-
"@wordpress/i18n": "^4.58.0",
3128
"@wordpress/hooks": "^3.58.0",
29+
"@wordpress/i18n": "^4.58.0",
3230
"@wordpress/stylelint-config": "^24.2.0",
3331
"clean-webpack-plugin": "^4.0.0",
3432
"css-loader": "^7.1.4",
35.8 KB
Binary file not shown.
28.2 KB
Binary file not shown.

‎src/scss/01-abstract/_variables.scss‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,18 @@ $base-border-radius: 3px;
7171
// ----
7272
// Font Family
7373
// ----
74-
$font-family-primary: "Poppins", "Poppins-fallback", sans-serif;
74+
$font-family-primary: $settings-font-family-primary;
75+
$font-family-secondary: $settings-font-family-secondary;
7576

7677
// ----
7778
// Font Size
7879
// ----
79-
$font-size-base: var(--paragraph--font-size-default);
80-
$font-size-sm: var(--paragraph--font-size-small);
81-
$font-size-lg: var(--paragraph--font-size-large);
82-
$font-size-xl: var(--paragraph--font-size-huge);
80+
$font-size-base: $settings-font-size-default;
81+
$font-size-sm: $settings-font-size-small;
82+
$font-size-lg: $settings-font-size-large;
83+
$font-size-xl: $settings-font-size-huge;
8384

8485
// ----
8586
// Line Height
8687
// ----
87-
$line-height-base: var(--paragraph--line-height-default);
88+
$line-height-base: $settings-custom-line-height-default;

‎src/scss/02-tools/_m-heading.scss‎

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@use "../01-abstract/variables" as *;
2+
@use "../01-abstract/theme-json" as *;
23

34
/**
45
* Heading - Used in src/scss/06-blocks/core/_heading.scss
@@ -20,8 +21,8 @@
2021
*
2122
* mixin :
2223
* @if $name == h3 {
23-
* font-size: var(--heading--font-size-h3);
24-
* line-height: var(--heading--line-height-h3);
24+
* font-size: $settings-font-size-h3;
25+
* line-height: $settings-custom-line-height-h3;
2526
*
2627
* @if $style == uppercase {
2728
* text-transform: uppercase;
@@ -44,36 +45,41 @@
4445
*/
4546

4647
@mixin heading($name: h1, $style: default) {
47-
font-family: $font-family-primary;
48-
font-weight: 400;
48+
font-family: $font-family-secondary;
4949

5050
@if $name == h1 {
51-
font-size: var(--heading--font-size-h1);
52-
line-height: var(--heading--line-height-h1);
51+
font-size: $settings-font-size-h1;
52+
font-weight: 500;
53+
line-height: $settings-custom-line-height-h1;
5354
}
5455

5556
@if $name == h2 {
56-
font-size: var(--heading--font-size-h2);
57-
line-height: var(--heading--line-height-h2);
57+
font-size: $settings-font-size-h2;
58+
font-weight: 500;
59+
line-height: $settings-custom-line-height-h2;
5860
}
5961

6062
@if $name == h3 {
61-
font-size: var(--heading--font-size-h3);
62-
line-height: var(--heading--line-height-h3);
63+
font-size: $settings-font-size-h3;
64+
font-weight: 500;
65+
line-height: $settings-custom-line-height-h3;
6366
}
6467

6568
@if $name == h4 {
66-
font-size: var(--heading--font-size-h4);
67-
line-height: var(--heading--line-height-h4);
69+
font-size: $settings-font-size-h4;
70+
font-weight: 500;
71+
line-height: $settings-custom-line-height-h4;
6872
}
6973

7074
@if $name == h5 {
71-
font-size: var(--heading--font-size-h5);
72-
line-height: var(--heading--line-height-h5);
75+
font-size: $settings-font-size-h5;
76+
font-weight: 500;
77+
line-height: $settings-custom-line-height-h5;
7378
}
7479

7580
@if $name == h6 {
76-
font-size: var(--heading--font-size-h6);
77-
line-height: var(--heading--line-height-h6);
81+
font-size: $settings-font-size-h6;
82+
font-weight: 500;
83+
line-height: $settings-custom-line-height-h6;
7884
}
7985
}

‎src/scss/02-tools/_m-text.scss‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
@use "../01-abstract/variables" as *;
2+
@use "../01-abstract/theme-json" as *;
3+
14
/**
25
* Text - Used in src/scss/06-blocks/core/_paragraph.scss and src/scss/03-base/_text.scss
36
*
@@ -15,26 +18,26 @@
1518

1619
@mixin text($name: default) {
1720
@if $name == default {
18-
font-size: var(--paragraph--font-size-default);
21+
font-size: $settings-font-size-default;
1922
font-weight: 400;
20-
line-height: var(--paragraph--line-height-default);
23+
line-height: $settings-custom-line-height-default;
2124
}
2225

2326
@if $name == small {
24-
font-size: var(--paragraph--font-size-small);
27+
font-size: $settings-font-size-small;
2528
font-weight: 400;
26-
line-height: var(--paragraph--line-height-small);
29+
line-height: $settings-custom-line-height-default;
2730
}
2831

2932
@if $name == large {
30-
font-size: var(--paragraph--font-size-large);
33+
font-size: $settings-font-size-large;
3134
font-weight: 400;
32-
line-height: var(--paragraph--line-height-large);
35+
line-height: $settings-custom-line-height-default;
3336
}
3437

3538
@if $name == huge {
36-
font-size: var(--paragraph--font-size-huge);
39+
font-size: $settings-font-size-huge;
3740
font-weight: 400;
38-
line-height: var(--paragraph--line-height-huge);
41+
line-height: $settings-custom-line-height-default;
3942
}
4043
}

0 commit comments

Comments
 (0)