-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: mapping grid item to schema props
- Loading branch information
1 parent
95e5546
commit 70a2215
Showing
8 changed files
with
184 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 63 additions & 45 deletions
108
...site/src/pages/pattern-lab/_patterns/02-components/grid/20-grid-item-size-variations.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 32 additions & 32 deletions
64
...ite/src/pages/pattern-lab/_patterns/02-components/grid/25-grid-item-align-variations.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{% set item_attributes = create_attribute(attributes|default({})) %} | ||
|
||
{% set item_row_start = item.row_start %} | ||
{% set item_row_span = item.row_span %} | ||
{% set item_column_start = item.column_start %} | ||
{% set item_column_span = item.column_span %} | ||
{% set item_valign = item.valign %} | ||
|
||
{# Set up checks to validate that the component's prop values are allowed, based on the component's schema #} | ||
{% set item_row_start_options = schema.properties.item_row_start.enum %} | ||
{% set row_span_options = schema.properties.item_row_span.enum %} | ||
{% set column_start_options = schema.properties.item_column_start.enum %} | ||
{% set column_span_options = schema.properties.item_column_span.enum %} | ||
{% set valign_options = schema.properties.item_valign.enum %} | ||
|
||
{# Check that the component's current prop values are valid. if not, default to the schema default #} | ||
{% set item_row_start = item_row_start in item_row_start_options ? item_row_start : schema.properties.item_row_start.default %} | ||
{% set item_row_span = item_row_span in item_row_span_options ? item_row_span : schema.properties.item_row_span.default %} | ||
{% set item_column_start = item_column_start in item_column_start_options ? item_column_start : schema.properties.item_column_start.default %} | ||
{% set item_column_span = item_column_span in item_column_span_options ? item_column_span : schema.properties.item_column_span.default %} | ||
{% set item_valign = item_valign in item_valign_options ? item_valign : schema.properties.item_valign.default %} | ||
|
||
<bolt-grid-item | ||
{% if row_start %}row-start="{{ row_start }}"{% endif %} | ||
{% if row_span %}row-span="{{ row_span }}"{% endif %} | ||
{% if column_start %}column-start="{{ column_start }}"{% endif %} | ||
{% if column_span %}column-span="{{ column_span }}"{% endif %} | ||
{% if valign %}valign="{{ valign }}"{% endif %} | ||
{{ item_attributes }} | ||
> | ||
{{ content }} | ||
</bolt-grid-item> |
Oops, something went wrong.