-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathadvanced-example.json.php
155 lines (141 loc) · 5.73 KB
/
advanced-example.json.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
declare(strict_types=1);
namespace ItalyStrap\Tests;
use ItalyStrap\ThemeJsonGenerator\Application\Config\Blueprint;
use ItalyStrap\ThemeJsonGenerator\Domain\Input\SectionNames;
use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Duotone;
use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Gradient;
use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Palette;
use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Shadow;
use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities\BoxShadow;
use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities\Color;
use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities\ColorModifier;
use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities\LinearGradient;
use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Custom\CustomToPresets;
use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Presets;
use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Typography\FontFamily;
use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Typography\FontSize;
use ItalyStrap\ThemeJsonGenerator\Domain\Input\Styles;
use Psr\Container\ContainerInterface;
return static function (Blueprint $blueprint, Presets $presets, ContainerInterface $container): void {
$baseClr = (new Color('#3986E0'))->toHsla();
$bodyText = (new Color('#000000'))->toHsla();
$headingText = (new ColorModifier($bodyText))->lighten(20);
$baseClrPalette = new Palette('base', 'Brand base color', $baseClr);
$bodyClrPalette = new Palette('bodyColor', 'Color for text', $bodyText);
$headingClrPalette = new Palette('headingColor', 'Color for headings', $headingText);
$presets
->add($baseClrPalette)
->add($bodyClrPalette)
->add($headingClrPalette);
// Gradient
$presets
->add(new Gradient(
'base-to-white',
'Base to white',
(new LinearGradient())
->direction('135deg')
->colorStop($presets->get('color.base'))
->colorStop($presets->get('color.bodyColor'))
));
// Duotone
$presets
->add(new Duotone(
'base-to-bodyColor',
'Base to Body Color',
$presets->get('color.base'),
$presets->get('color.bodyColor')
));
$presets
->add(new Shadow(
'base',
'Base shadow',
(new BoxShadow())
->offsetX('0')
->offsetY('4px')
->blur('8px')
->spread('0')
->color($presets->get('color.bodyColor')),
(new BoxShadow())
->inset()
->offsetX('0')
->offsetY('4px')
->blur('8px')
->spread('0')
->color('#fff')
));
// Font size
$presets
->add(new FontSize('base', 'Base font size 16px', 'clamp(1rem, 2vw, 1.5rem)'))
->add(new FontSize('h1', 'Used in H1 titles', 'calc( {{fontSize.base}} * 2.8125)'));
// ... more font sizes
// Font Family
$presets
->add(new FontFamily(
'base',
'Default font family',
// phpcs:disable
'system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"'
// phpcs:enable
));
$collectionAdapter = new CustomToPresets([
'contentSize' => 'clamp(16rem, 60vw, 60rem)',
'wideSize' => 'clamp(16rem, 85vw, 70rem)',
'baseFontSize' => "1rem",
'spacer' => [
'base' => '1rem',
// ... more spacers
],
]);
$presets
->addMultiple(
$collectionAdapter->toArray()
);
$blueprint->merge([
SectionNames::SCHEMA => 'https://schemas.wp.org/trunk/theme.json',
SectionNames::VERSION => 2,
SectionNames::TITLE => 'Experimental Theme',
SectionNames::DESCRIPTION => 'Experimental Theme',
SectionNames::SETTINGS => [
'color' => [
'custom' => true,
'link' => true,
],
'typography' => [
'customFontSize' => true,
],
'spacing' => [
'blockGap' => true,
'units' => [ '%', 'px', 'em', 'rem', 'vh', 'vw' ]
],
'layout' => [
'contentSize' => $presets->get('custom.contentSize')->var(),
'wideSize' => $presets->get('custom.wideSize')->var(),
],
],
SectionNames::STYLES => [
'color' => (new Styles\Color())
->background('var(--wp--preset--color--body-bg)')
->text('var(--wp--preset--color--body-color)'),
'typography' => (new Styles\Typography($presets))
->fontSize(FontSize::TYPE . '.base')
->fontFamily(FontFamily::TYPE . '.base'),
'elements' => [
'link' => [ // .wp-block-file a
'color' => $container->get(Styles\Color::class)
->text(Palette::TYPE . '.base')
->background('transparent'),
],
],
'blocks' => [
'core/paragraph' => [
'color' => (new Styles\Color())
->text('var(--wp--preset--color--body-color)'),
'typography' => (new Styles\Typography())
->fontSize('var(--wp--preset--font-size--base)')
->fontFamily('var(--wp--preset--font-family--base)'),
],
],
],
]);
};