Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/style-engine/class-wp-style-engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ final class WP_Style_Engine {
),
'path' => array( 'typography', 'lineHeight' ),
),
'textColumns' => array(
'property_keys' => array(
'default' => 'column-count',
),
'path' => array( 'typography', 'textColumns' ),
),
'textDecoration' => array(
'property_keys' => array(
'default' => 'text-decoration',
Expand Down
13 changes: 13 additions & 0 deletions packages/style-engine/src/styles/typography/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ const lineHeight = {
},
};

const textColumns = {
name: 'textColumns',
generate: ( style: Style, options: StyleOptions ) => {
return generateRule(
style,
options,
[ 'typography', 'textColumns' ],
'columnCount'
);
},
};

const textDecoration = {
name: 'textDecoration',
generate: ( style: Style, options: StyleOptions ) => {
Expand Down Expand Up @@ -107,6 +119,7 @@ export default [
fontWeight,
letterSpacing,
lineHeight,
textColumns,
textDecoration,
textTransform,
];
9 changes: 8 additions & 1 deletion packages/style-engine/src/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ describe( 'generate', () => {
fontWeight: '800',
fontFamily: "'Helvetica Neue',sans-serif",
lineHeight: '3.3',
textColumns: '2',
textDecoration: 'line-through',
letterSpacing: '12px',
textTransform: 'uppercase',
Expand All @@ -88,7 +89,7 @@ describe( 'generate', () => {
}
)
).toEqual(
".some-selector { color: #cccccc; background: linear-gradient(135deg,rgb(255,203,112) 0%,rgb(33,32,33) 42%,rgb(65,88,208) 100%); background-color: #111111; min-height: 50vh; outline-color: red; outline-style: dashed; outline-offset: 2px; outline-width: 4px; margin-top: 11px; margin-right: 12px; margin-bottom: 13px; margin-left: 14px; padding-top: 10px; padding-bottom: 5px; font-family: 'Helvetica Neue',sans-serif; font-size: 2.2rem; font-style: italic; font-weight: 800; letter-spacing: 12px; line-height: 3.3; text-decoration: line-through; text-transform: uppercase; }"
".some-selector { color: #cccccc; background: linear-gradient(135deg,rgb(255,203,112) 0%,rgb(33,32,33) 42%,rgb(65,88,208) 100%); background-color: #111111; min-height: 50vh; outline-color: red; outline-style: dashed; outline-offset: 2px; outline-width: 4px; margin-top: 11px; margin-right: 12px; margin-bottom: 13px; margin-left: 14px; padding-top: 10px; padding-bottom: 5px; font-family: 'Helvetica Neue',sans-serif; font-size: 2.2rem; font-style: italic; font-weight: 800; letter-spacing: 12px; line-height: 3.3; column-count: 2; text-decoration: line-through; text-transform: uppercase; }"
);
} );

Expand Down Expand Up @@ -242,6 +243,7 @@ describe( 'getCSSRules', () => {
fontWeight: '800',
fontFamily: "'Helvetica Neue',sans-serif",
lineHeight: '3.3',
textColumns: '2',
textDecoration: 'line-through',
letterSpacing: '12px',
textTransform: 'uppercase',
Expand Down Expand Up @@ -349,6 +351,11 @@ describe( 'getCSSRules', () => {
key: 'lineHeight',
value: '3.3',
},
{
selector: '.some-selector',
key: 'columnCount',
value: '2',
},
{
selector: '.some-selector',
key: 'textDecoration',
Expand Down
1 change: 1 addition & 0 deletions packages/style-engine/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface Style {
fontStyle?: CSSProperties[ 'fontStyle' ];
letterSpacing?: CSSProperties[ 'letterSpacing' ];
lineHeight?: CSSProperties[ 'lineHeight' ];
textColumns?: CSSProperties[ 'columnCount' ];
textDecoration?: CSSProperties[ 'textDecoration' ];
textTransform?: CSSProperties[ 'textTransform' ];
};
Expand Down
4 changes: 3 additions & 1 deletion phpunit/style-engine/style-engine-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,22 @@ public function data_wp_style_engine_get_styles() {
'fontStyle' => 'italic',
'fontWeight' => '800',
'lineHeight' => '1.3',
'textColumns' => '2',
'textDecoration' => 'underline',
'textTransform' => 'uppercase',
'letterSpacing' => '2',
),
),
'options' => null,
'expected_output' => array(
'css' => 'font-size:clamp(2em, 2vw, 4em);font-family:Roboto,Oxygen-Sans,Ubuntu,sans-serif;font-style:italic;font-weight:800;line-height:1.3;text-decoration:underline;text-transform:uppercase;letter-spacing:2;',
'css' => 'font-size:clamp(2em, 2vw, 4em);font-family:Roboto,Oxygen-Sans,Ubuntu,sans-serif;font-style:italic;font-weight:800;line-height:1.3;column-count:2;text-decoration:underline;text-transform:uppercase;letter-spacing:2;',
'declarations' => array(
'font-size' => 'clamp(2em, 2vw, 4em)',
'font-family' => 'Roboto,Oxygen-Sans,Ubuntu,sans-serif',
'font-style' => 'italic',
'font-weight' => '800',
'line-height' => '1.3',
'column-count' => '2',
'text-decoration' => 'underline',
'text-transform' => 'uppercase',
'letter-spacing' => '2',
Expand Down