-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs(web-twig): Introduce
DocsSection
and DocsBox
components
- New components: `DocsSection`, `DocsBox`. - CSS class `docs-FormFieldGrid` has been dropped. `DocsSection` displays title and automatically provides proper spacing to its content. Before: ```html <section class="docs-Section"> <h2 class="docs-Heading"> Basic Usage <span class="Tag Tag--warning Tag--medium Tag--subtle">Visual demo only</span> </h2> <div class="docs-FormFieldGrid"> <div class="docs-Box">…</div> </div> </section> ``` After: ```twig <DocsSection title="Basic Usage" tag="Visual demo only"> <DocsBox>…</DocsBox> </DocsSection> ```
- Loading branch information
1 parent
e9dfab2
commit fcb97dc
Showing
15 changed files
with
159 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
spirit_web_twig: | ||
paths: | ||
- '%kernel.project_dir%/../spirit-web-twig-bundle/docs/components' | ||
- '%kernel.project_dir%/../spirit-web-twig-bundle/docs/twig-components' | ||
icons: | ||
paths: | ||
- '%kernel.project_dir%/../spirit-web-twig-bundle/static' |
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,19 @@ | ||
{# API #} | ||
{%- set props = props | default([]) -%} | ||
{%- set _size = props.size | default('medium') -%} | ||
|
||
{# Class names #} | ||
{%- set _rootClassName = 'docs-Box' -%} | ||
{%- set _rootSizeClassName = 'docs-Box--' ~ _size -%} | ||
|
||
{# Miscellaneous #} | ||
{%- set _styleProps = useStyleProps(props) -%} | ||
{%- set _rootClassNames = [_rootClassName, _rootSizeClassName, _styleProps.className] -%} | ||
|
||
<div | ||
{{ mainProps(props) }} | ||
{{ styleProp(_styleProps) }} | ||
{{ classProp(_rootClassNames) }} | ||
> | ||
{% block content %}{% endblock %} | ||
</div> |
11 changes: 11 additions & 0 deletions
11
packages/web-twig/docs/components/DocsBox/__tests__/DocsBoxSnapshotTest.php
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,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Lmc\SpiritWebTwigBundle\Resources\components\DocsBox; | ||
|
||
use Lmc\SpiritWebTwigBundle\AbstractComponentSnapshotTest; | ||
|
||
class DocsBoxSnapshotTest extends AbstractComponentSnapshotTest | ||
{ | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/web-twig/docs/components/DocsBox/__tests__/__fixtures__/docsBoxDefault.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<DocsBox /> | ||
|
||
<!-- Render with content --> | ||
<DocsBox>my content</DocsBox> | ||
|
||
<!-- Render with all props --> | ||
<DocsBox size="small">my content</DocsBox> |
21 changes: 21 additions & 0 deletions
21
...es/web-twig/docs/components/DocsBox/__tests__/__snapshots__/docsBoxDefault.twig.snap.html
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,21 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<title> | ||
</title> | ||
</head> | ||
<body> | ||
<div class="docs-Box docs-Box--medium"> | ||
</div> | ||
<!-- Render with content --> | ||
|
||
<div class="docs-Box docs-Box--medium"> | ||
my content | ||
</div> | ||
<!-- Render with all props --> | ||
|
||
<div class="docs-Box docs-Box--small"> | ||
my content | ||
</div> | ||
</body> | ||
</html> |
32 changes: 32 additions & 0 deletions
32
packages/web-twig/docs/components/DocsSection/DocsSection.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{# API #} | ||
{%- set props = props | default([]) -%} | ||
{%- set _hasFluidLayout = props.hasFluidLayout | default(false) -%} | ||
{%- set _tag = props.tag | default(null) -%} | ||
{%- set _title = props.title -%} | ||
|
||
{# Class names #} | ||
{%- set _rootClassName = 'docs-Section' -%} | ||
{%- set _headingClassName = 'docs-Heading' -%} | ||
{%- set _stackClassName = 'docs-Stack' -%} | ||
{%- set _stackFluidClassName = _hasFluidLayout ? 'docs-Stack--fluid' : null -%} | ||
|
||
{# Miscellaneous #} | ||
{%- set _styleProps = useStyleProps(props) -%} | ||
{%- set _rootClassNames = [_rootClassName, _styleProps.className] -%} | ||
{%- set _stackClassNames = [_stackClassName, _stackFluidClassName] -%} | ||
|
||
<section | ||
{{ mainProps(props) }} | ||
{{ styleProp(_styleProps) }} | ||
{{ classProp(_rootClassNames) }} | ||
> | ||
<h2 class="{{ _headingClassName }}"> | ||
{{ _title }} | ||
{% if _tag %} | ||
<Tag color="warning" isSubtle>{{ _tag }}</Tag> | ||
{% endif %} | ||
</h2> | ||
<div {{ classProp(_stackClassNames) }}> | ||
{% block content %}{% endblock %} | ||
</div> | ||
</section> |
11 changes: 11 additions & 0 deletions
11
packages/web-twig/docs/components/DocsSection/__tests__/DocsSectionSnapshotTest.php
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,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Lmc\SpiritWebTwigBundle\Resources\components\DocsSection; | ||
|
||
use Lmc\SpiritWebTwigBundle\AbstractComponentSnapshotTest; | ||
|
||
class DocsSectionSnapshotTest extends AbstractComponentSnapshotTest | ||
{ | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/web-twig/docs/components/DocsSection/__tests__/__fixtures__/docsSectionDefault.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<DocsSection title="My Title" /> | ||
|
||
<!-- Render with all props --> | ||
<DocsSection tag="My tag" title="My Title">my content</DocsSection> |
28 changes: 28 additions & 0 deletions
28
...wig/docs/components/DocsSection/__tests__/__snapshots__/docsSectionDefault.twig.snap.html
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,28 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<title> | ||
</title> | ||
</head> | ||
<body> | ||
<section class="docs-Section"> | ||
<h2 class="docs-Heading"> | ||
My Title | ||
</h2> | ||
|
||
<div class="docs-Stack"> | ||
</div> | ||
</section> | ||
<!-- Render with all props --> | ||
|
||
<section class="docs-Section"> | ||
<h2 class="docs-Heading"> | ||
My Title <span class="Tag Tag--warning Tag--medium Tag--subtle">My tag</span> | ||
</h2> | ||
|
||
<div class="docs-Stack"> | ||
my content | ||
</div> | ||
</section> | ||
</body> | ||
</html> |
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 @@ | ||
{% extends '@spirit/DocsBox/DocsBox.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{% extends '@spirit/DocsSection/DocsSection.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