-
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-react, web-twig): Add DocsStack component
- Created new `DocsStack` component and use it in `DocsSection` component for both web-react and web-twig
- Loading branch information
1 parent
340613d
commit a52215d
Showing
8 changed files
with
81 additions
and
6 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
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,18 @@ | ||
import React, { ReactNode } from 'react'; | ||
|
||
interface DocsStackProps { | ||
children: ReactNode; | ||
stackAlignment?: 'start' | 'center' | 'end'; | ||
} | ||
|
||
const DocsStack = ({ children, stackAlignment }: DocsStackProps) => { | ||
const alignmentClass = stackAlignment ? `docs-Stack--${stackAlignment}` : ''; | ||
|
||
return <div className={`docs-Stack ${alignmentClass}`}>{children}</div>; | ||
}; | ||
|
||
DocsStack.defaultProps = { | ||
stackAlignment: '', | ||
}; | ||
|
||
export default DocsStack; |
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
19 changes: 19 additions & 0 deletions
19
packages/web-twig/docs/components/DocsStack/DocsStack.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,19 @@ | ||
{# API #} | ||
{%- set props = props | default([]) -%} | ||
{%- set _stackAlignment = props.stackAlignment | default('') -%} | ||
|
||
{# Class names #} | ||
{%- set _rootClassName = 'docs-Stack' -%} | ||
{%- set _rootSizeClassName = _stackAlignment ? 'docs-Stack--' ~ _stackAlignment : '' -%} | ||
|
||
{# 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/DocsStack/__tests__/DocsStackSnapshotTest.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\DocsStack; | ||
|
||
use Lmc\SpiritWebTwigBundle\AbstractComponentSnapshotTest; | ||
|
||
class DocsStackSnapshotTest extends AbstractComponentSnapshotTest | ||
{ | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/web-twig/docs/components/DocsStack/__tests__/__fixtures__/docsStackDefault.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 @@ | ||
<DocsStack /> | ||
|
||
<!-- Render with content --> | ||
<DocsStack>my content</DocsStack> | ||
|
||
<!-- Render with all props --> | ||
<DocsStack stackAlignment="start">my content</DocsStack> |
21 changes: 21 additions & 0 deletions
21
...eb-twig/docs/components/DocsStack/__tests__/__snapshots__/docsStackDefault.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-Stack"> | ||
</div> | ||
<!-- Render with content --> | ||
|
||
<div class="docs-Stack"> | ||
my content | ||
</div> | ||
<!-- Render with all props --> | ||
|
||
<div class="docs-Stack docs-Stack--start"> | ||
my content | ||
</div> | ||
</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/DocsStack/DocsStack.twig' %} |