Transitioning from CSS Block Styling to theme.json
in LSX Design Theme
#188
Pinned
ashleyshaw
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Current Setup Overview
After reviewing the current approach to block styling in the LSX Design theme, it’s evident that the team has relied heavily on CSS for block-specific styles. This includes:
heading.css
): Font sizes, weights, and line heights defined using CSS for different heading styles.button.css
): Extensive use of CSS for button states, hover effects, and padding settings.columns.css
): Styling of columns with borders, shadows, and responsive adjustments in CSS.group.css
): Shadows and borders defined using CSS.paragraph.css
): Custom font sizes and subheading styles using CSS.Additionally, there’s a custom
editor-style.css
to support block editor styling, which is necessary due to the reliance on CSS for block styling.Challenges with the Current Setup
Extensive CSS Dependency:
Editor Compatibility:
editor-style.css
increases complexity, and editor previews aren’t as accurate.Redundancy in Styling:
theme.json
. This leads to redundant styling rules that can instead be centralized in JSON.Recommended Transition to
theme.json
To optimize the LSX Design theme, it’s recommended to transition block styles from CSS to
theme.json
. This approach will:theme.json
, both the front-end and editor will share the same styling definitions.theme.json
are automatically applied in the block editor, ensuring a true WYSIWYG experience.Proposed Steps for Transitioning Specific Blocks
1. Headings (
heading.css
)theme.json
using block-specific styles forcore/heading
.2. Buttons (
button.css
)theme.json
, using it for hover states, background colors, and border-radius settings.3. Columns (
columns.css
)theme.json
file for thecore/columns
block.4. Group (
group.css
)wp-block-group
class has box-shadow and border styles applied using CSS.theme.json
for thecore/group
block.5. Paragraphs (
paragraph.css
)theme.json
.General Benefits of Transitioning to
theme.json
theme.json
, maintenance becomes simpler as all design changes are applied globally across both the editor and front-end.theme.json
structure.Conclusion
Transitioning your block styling from CSS to
theme.json
will greatly enhance maintainability, consistency, and performance for the LSX Design theme. By focusing on a JSON-based approach, you will simplify your styling process and improve compatibility with future WordPress updates and the block editor.If you require further assistance with implementing this approach or need help converting additional styles, feel free to reach out!
Beta Was this translation helpful? Give feedback.
All reactions