You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<SettingPreviewimage="/setting-spacing.png"title="Spacing setting type preview"/>
376
376
377
377
::: info
378
+
378
379
- Default values: All sides default to `0` if not specified
379
380
- The visual editor includes a link toggle to sync all sides
380
381
- Negative values are supported for margins (set appropriate min value)
381
-
:::
382
+
:::
382
383
383
384
---
384
385
@@ -925,6 +926,324 @@ Bagisto Visual provides a helper method to generate the full CSS output automati
925
926
926
927
---
927
928
929
+
### Typography
930
+
931
+
The `Typography` setting allows merchants to select a typography preset for text styling. Typography presets are defined once in the theme's settings using [TypographyPresets](#typographypresets), and sections or blocks can reference them using this setting.
<h1data-typography="heading">Welcome to our store</h1>
961
+
```
962
+
963
+
The `data-typography` attribute scopes typography CSS variables to this element.
964
+
965
+
<SettingPreviewimage="/setting-typography.png"title="Typography setting type preview"/>
966
+
967
+
---
968
+
969
+
### TypographyPresets
970
+
971
+
The `TypographyPresets` setting type allows theme developers to define a **set of named typography presets** that merchants can reuse across multiple sections. Each typography preset is a collection of font properties (fontFamily, fontSize, lineHeight, etc.) that can be selected using a [Typography](#typography) setting.
972
+
973
+
This is typically defined once in your theme's `config/settings.php` and is **editable by the merchant**.
974
+
975
+
- Acts as the **central registry of available typography presets**
976
+
- Enables consistency in text styling across sections
977
+
- Supports responsive typography for fontSize and lineHeight
978
+
- Merchants can add, edit, or remove presets in the theme editor
979
+
980
+
#### Usage in `config/settings.php`
981
+
982
+
```php
983
+
use BagistoPlus\Visual\Settings\TypographyPresets;
<SettingPreviewimage="/setting-typography-presets.png"title="Typography presets setting type preview"/>
1009
+
1010
+
#### Generating CSS
1011
+
1012
+
After defining typography presets, you must generate the CSS in your theme's layout file. This makes the typography styles available to all sections using the `Typography` setting.
1013
+
1014
+
**Basic Usage:**
1015
+
1016
+
```blade
1017
+
{{-- layouts/default.blade.php --}}
1018
+
<style>
1019
+
@foreach ($theme->settings->typography_presets as $typography)
1020
+
{!! $typography->toCss() !!}
1021
+
@endforeach
1022
+
</style>
1023
+
1024
+
{{-- Load fonts from Bunny Fonts --}}
1025
+
@pushOnce('styles')
1026
+
@foreach ($theme->settings->typography_presets as $typography)
1027
+
{!! $typography->toHtml() !!}
1028
+
@endforeach
1029
+
@endPushOnce
1030
+
```
1031
+
1032
+
This generates CSS for typography styles:
1033
+
1034
+
```css
1035
+
[data-typography='heading'] {
1036
+
--typography-font-family: 'Inter', sans-serif;
1037
+
--typography-font-style: normal;
1038
+
--typography-font-size: 1.5rem;
1039
+
--typography-line-height: 1.25;
1040
+
--typography-letter-spacing: 0em;
1041
+
--typography-text-transform: none;
1042
+
}
1043
+
1044
+
[data-typography='body'] {
1045
+
--typography-font-family: 'Inter', sans-serif;
1046
+
--typography-font-style: normal;
1047
+
--typography-font-size: 1rem;
1048
+
--typography-line-height: 1.5;
1049
+
--typography-letter-spacing: 0em;
1050
+
--typography-text-transform: none;
1051
+
}
1052
+
```
1053
+
1054
+
And generates HTML to load fonts from Bunny Fonts:
0 commit comments