-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v4-dev' into FRONT-4607-banner-corner
- Loading branch information
Showing
50 changed files
with
781 additions
and
420 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 |
---|---|---|
|
@@ -89,7 +89,7 @@ | |
{% if _required %} | ||
required | ||
{% endif %} | ||
/> | ||
> | ||
<label | ||
{% if _id %} | ||
for="{{ _id }}" | ||
|
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 |
---|---|---|
|
@@ -89,7 +89,7 @@ | |
{% if _lazy %} | ||
loading="lazy" | ||
{% endif %} | ||
/> | ||
> | ||
{% endif %} | ||
</picture> | ||
|
||
|
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 |
---|---|---|
|
@@ -91,7 +91,7 @@ | |
{% if _required %} | ||
required | ||
{% endif %} | ||
/> | ||
> | ||
|
||
<label | ||
class="{{ _label_css_class }}" | ||
|
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,21 @@ | ||
# ECL separator component | ||
|
||
npm package: `@ecl/twig-component-separator` | ||
|
||
### Parameters: | ||
|
||
- **"extra_classes"** (optional) (string) (default: '') Extra classes (space separated) | ||
- **"extra_attributes"** (optional) (array) (default: []) Extra attributes | ||
- "name" (string) Attribute name, eg. 'data-test' | ||
- "value" (string) Attribute value, eg: 'data-test-1' | ||
|
||
```shell | ||
npm install --save @ecl/twig-component-separator | ||
``` | ||
|
||
### Example: | ||
|
||
<!-- prettier-ignore --> | ||
```twig | ||
{% include '@ecl/separator/separator.html.twig' %} | ||
``` |
27 changes: 27 additions & 0 deletions
27
src/implementations/twig/components/separator/__snapshots__/separator.test.js.snap
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,27 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Separator Default renders correctly 1`] = ` | ||
<jest> | ||
<hr | ||
class="ecl-separator" | ||
/> | ||
</jest> | ||
`; | ||
|
||
exports[`Separator Default renders correctly with extra attributes 1`] = ` | ||
<jest> | ||
<hr | ||
class="ecl-separator" | ||
data-test="data-test-value" | ||
data-test-1="data-test-value-1" | ||
/> | ||
</jest> | ||
`; | ||
|
||
exports[`Separator Default renders correctly with extra class names 1`] = ` | ||
<jest> | ||
<hr | ||
class="ecl-separator custom-class custom-class--test" | ||
/> | ||
</jest> | ||
`; |
27 changes: 27 additions & 0 deletions
27
src/implementations/twig/components/separator/package.json
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,27 @@ | ||
{ | ||
"name": "@ecl/twig-component-separator", | ||
"author": "European Commission", | ||
"license": "EUPL-1.2", | ||
"version": "4.6.3", | ||
"description": "ECL Separator", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"devDependencies": { | ||
"@ecl/vanilla-component-separator": "4.6.3" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/ec-europa/europa-component-library.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/ec-europa/europa-component-library/issues" | ||
}, | ||
"homepage": "https://github.com/ec-europa/europa-component-library", | ||
"keywords": [ | ||
"ecl", | ||
"europa-component-library", | ||
"design-system", | ||
"twig" | ||
] | ||
} |
39 changes: 39 additions & 0 deletions
39
src/implementations/twig/components/separator/separator.html.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,39 @@ | ||
{% apply spaceless %} | ||
|
||
{# | ||
Parameters: | ||
- "extra_classes" (optional) (string) (default: '') Extra classes (space separated) for the icon | ||
- "extra_attributes" (optional) (array) (default: []) Extra attributes for icon | ||
- "name" (string) Attribute name, eg. 'data-test' | ||
- "value" (optional) (string) Attribute value, eg: 'data-test-1' | ||
#} | ||
|
||
{# Internal properties #} | ||
|
||
{% set _css_class = 'ecl-separator' %} | ||
{% set _extra_attributes = '' %} | ||
|
||
{# Internal logic - Process properties #} | ||
|
||
{% if extra_classes is defined and extra_classes is not empty %} | ||
{% set _css_class = _css_class ~ ' ' ~ extra_classes %} | ||
{% endif %} | ||
|
||
{% if extra_attributes is defined and extra_attributes is not empty and extra_attributes is iterable %} | ||
{% for attr in extra_attributes %} | ||
{% if attr.value is defined %} | ||
{% set _extra_attributes = _extra_attributes ~ ' ' ~ attr.name|e('html_attr') ~ '="' ~ attr.value|e('html_attr') ~ '"' %} | ||
{% else %} | ||
{% set _extra_attributes = _extra_attributes ~ ' ' ~ attr.name|e('html_attr') %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
|
||
{# Print the result #} | ||
|
||
<hr | ||
class="{{ _css_class }}" | ||
{{ _extra_attributes|raw }} | ||
> | ||
|
||
{% endapply %} |
50 changes: 50 additions & 0 deletions
50
src/implementations/twig/components/separator/separator.story.js
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,50 @@ | ||
import { withNotes } from '@ecl/storybook-addon-notes'; | ||
import withCode from '@ecl/storybook-addon-code'; | ||
|
||
import separator from './separator.html.twig'; | ||
import notes from './README.md'; | ||
|
||
export default { | ||
title: 'Components/Separator', | ||
decorators: [withNotes, withCode], | ||
parameters: { | ||
controls: { disable: true }, | ||
parameters: { layout: 'fullscreen' }, | ||
}, | ||
}; | ||
|
||
export const Default = (_, { loaded: { component } }) => component; | ||
|
||
Default.render = async () => { | ||
const renderedSeparator = `<ul class="ecl-unordered-list"> | ||
<li class="ecl-unordered-list__item">Unordered list</li> | ||
<li class="ecl-unordered-list__item">Unordered list | ||
<ul class="ecl-unordered-list"> | ||
<li class="ecl-unordered-list__item">Nested unordered list</li> | ||
<li class="ecl-unordered-list__item">Nested unordered list</li> | ||
</ul> | ||
</li> | ||
</ul> | ||
${await separator()} | ||
<ol class="ecl-ordered-list"> | ||
<li class="ecl-ordered-list__item">Ordered list</li> | ||
<li class="ecl-ordered-list__item">Ordered list <ol> | ||
<ol class="ecl-ordered-list"> | ||
<li class="ecl-ordered-list__item">Nested ordered list</li> | ||
<li class="ecl-ordered-list__item">Nested ordered list</li> | ||
</ol> | ||
</li> | ||
</ol> | ||
${await separator()} | ||
<dl class="ecl-description-list"> | ||
<dt class="ecl-description-list__term">Description term</dt> | ||
<dd class="ecl-description-list__definition">Description definition</dd> | ||
<dt class="ecl-description-list__term">Description term</dt> | ||
<dd class="ecl-description-list__definition">Description definition</dd> | ||
</dl>${await separator()}`; | ||
|
||
return renderedSeparator; | ||
}; | ||
|
||
Default.storyName = 'default'; | ||
Default.parameters = { notes: { markdown: notes } }; |
46 changes: 46 additions & 0 deletions
46
src/implementations/twig/components/separator/separator.test.js
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,46 @@ | ||
import { renderTwigFileAsNode, renderTwigFileAsHtml } from '@ecl/test-utils'; | ||
import { axe, toHaveNoViolations } from 'jest-axe'; | ||
|
||
expect.extend(toHaveNoViolations); | ||
|
||
describe('Separator', () => { | ||
const template = '@ecl/separator/separator.html.twig'; | ||
const render = (params) => renderTwigFileAsNode(template, params); | ||
|
||
describe('Default', () => { | ||
test('renders correctly', () => { | ||
expect.assertions(1); | ||
|
||
return expect(render()).resolves.toMatchSnapshot(); | ||
}); | ||
|
||
test('renders correctly with extra class names', () => { | ||
expect.assertions(1); | ||
|
||
const withExtraClasses = { | ||
extra_classes: 'custom-class custom-class--test', | ||
}; | ||
|
||
return expect(render(withExtraClasses)).resolves.toMatchSnapshot(); | ||
}); | ||
|
||
test('renders correctly with extra attributes', () => { | ||
expect.assertions(1); | ||
|
||
const withExtraAttributes = { | ||
extra_attributes: [ | ||
{ name: 'data-test', value: 'data-test-value' }, | ||
{ name: 'data-test-1', value: 'data-test-value-1' }, | ||
], | ||
}; | ||
|
||
return expect(render(withExtraAttributes)).resolves.toMatchSnapshot(); | ||
}); | ||
|
||
test(`passes the accessibility tests`, async () => { | ||
expect( | ||
await axe(await renderTwigFileAsHtml(template, {}, true)), | ||
).toHaveNoViolations(); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -75,6 +75,6 @@ | |
required | ||
{% endif %} | ||
{{ _extra_attributes|raw }} | ||
/> | ||
> | ||
|
||
{% endapply %} |
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
Oops, something went wrong.