Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try: Add buttons styles. #157

Merged
merged 8 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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 assets/css/button-outline.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.wp-block-button.is-style-outline
carolinan marked this conversation as resolved.
Show resolved Hide resolved
> .wp-block-button__link:not(.has-text-color, .has-background):hover {
background-color: var(--wp--preset--color--contrast, transparent);
color: var(--wp--preset--color--base);
border-color: var(--wp--preset--color--contrast, currentColor);
}
25 changes: 25 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,28 @@ function twentytwentyfive_enqueue_styles() {
);
}
add_action( 'wp_enqueue_scripts', 'twentytwentyfive_enqueue_styles' );

/**
* Enqueue custom block stylesheets
*
* @since Twenty Twenty-Five 1.0
* @return void
*/
function twentytwentyfive_block_stylesheets() {
/**
* The wp_enqueue_block_style() function allows us to enqueue a stylesheet
* for a specific block. These will only get loaded when the block is rendered
* (both in the editor and on the front end), improving performance
* and reducing the amount of data requested by visitors.
*/
wp_enqueue_block_style(
'core/button',
array(
'handle' => 'twentytwentyfive-button-style-outline',
'src' => get_parent_theme_file_uri( 'assets/css/button-outline.css' ),
'ver' => wp_get_theme( get_template() )->get( 'Version' ),
'path' => get_parent_theme_file_path( 'assets/css/button-outline.css' ),
)
);
}
add_action( 'init', 'twentytwentyfive_block_stylesheets' );
69 changes: 60 additions & 9 deletions theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,35 @@
"lineHeight": "1.4"
},
"blocks": {
"core/button": {
"typography": {
"fontSize": "var:preset|font-size|small"
},
"spacing": {
"padding": {
"bottom": "1rem",
"left": "2.25rem",
"right": "2.25rem",
"top": "1rem"
}
},
"variations": {
"outline": {
"border": {
"color": "var:preset|color|contrast",
"width": "1px"
},
"spacing": {
"padding": {
"bottom": "1rem",
"left": "2.25rem",
"right": "2.25rem",
"top": "1rem"
}
}
}
}
},
"core/code": {
"typography": {
"fontFamily": "var:preset|font-family|fira-code",
Expand Down Expand Up @@ -1111,20 +1140,42 @@
},
"elements": {
"button": {
"typography": {
"fontSize": "var:preset|font-size|small"
},
"color": {
"background": "var:preset|color|contrast",
"text": "var:preset|color|base"
},
"spacing": {
"padding": {
"bottom": "1rem",
"left": "2.25rem",
"right": "2.25rem",
"top": "1rem"
":active": {
"color": {
"background": "var:preset|color|accent-1",
"text": "var:preset|color|contrast"
}
},
":focus": {
"color": {
"background": "var:preset|color|accent-1",
"text": "var:preset|color|contrast"
},
"outline": {
"color": "var:preset|color|primary",
"offset": "2px",
"style": "dotted",
"width": "1px"
}
},
":hover": {
"color": {
"background": "var:preset|color|accent-1",
"text": "var:preset|color|contrast"
},
"border": {
"color": "var:preset|color|accent-1"
}
},
"border": {
"color": "var:preset|color|contrast",
"radius": "100px",
"width": "1px",
"style": "solid"
}
},
"caption": {
Expand Down
Loading