diff --git a/framework/components/ecl-context-navs/ecl-context-navs.config.js b/framework/components/ecl-context-navs/ecl-context-navs.config.js index d2b2be9b19e..3e32cda493b 100644 --- a/framework/components/ecl-context-navs/ecl-context-navs.config.js +++ b/framework/components/ecl-context-navs/ecl-context-navs.config.js @@ -7,5 +7,43 @@ module.exports = { _demo: { scripts: 'ECL.contextualNav();', }, + label: 'Label for contextual nav', + items: [ + { + target: '#', + title: 'Item one', + }, + { + target: '#', + title: 'Item two', + }, + { + target: '#', + title: 'Item three', + }, + { + target: '#', + title: 'Item four', + }, + ], + items_hidden: [ + { + target: '#', + title: 'Item five', + }, + { + target: '#', + title: 'Item six', + }, + { + target: '#', + title: 'Item seven', + }, + { + target: '#', + title: 'Item eight', + }, + ], + button_more: 'More', }, }; diff --git a/framework/components/ecl-context-navs/ecl-context-navs.twig b/framework/components/ecl-context-navs/ecl-context-navs.twig index 71292674f55..d73e95b785e 100644 --- a/framework/components/ecl-context-navs/ecl-context-navs.twig +++ b/framework/components/ecl-context-navs/ecl-context-navs.twig @@ -1,54 +1,27 @@
- Label for contextual nav + {{ label }} + {% if items is defined and items is iterable %}
+ {% for item in items %} - Item one - - - Item two - - - Item three - - - Item four - -
-
- -
- Label for longer list -
- - Item one - - - Item two - - - Item three - - - Item four + {{ item.title }} + {% endfor %} + {% endif %} + {% if items_hidden is defined and items_hidden is iterable %}
- More + {{ button_more }} +
+ {% for hidden_item in items_hidden %} - Item five - - - Item six - - - Item seven - - - Item eight + {{ hidden_item.title }} + {% endfor %}
+ {% endif %}
diff --git a/framework/components/ecl-profile-topbars/README.md b/framework/components/ecl-profile-topbars/README.md index e87fcce6a49..a11af75f5d1 100644 --- a/framework/components/ecl-profile-topbars/README.md +++ b/framework/components/ecl-profile-topbars/README.md @@ -1,4 +1,3 @@ # Profile topbar -Defines the profile topbar component -TODO: this component's behaviour needs to be rewritten without jQuery. +Defines the profile topbar component. diff --git a/framework/components/ecl-profile-topbars/_profile-topbars.scss b/framework/components/ecl-profile-topbars/_profile-topbars.scss deleted file mode 100644 index fc505627c25..00000000000 --- a/framework/components/ecl-profile-topbars/_profile-topbars.scss +++ /dev/null @@ -1,23 +0,0 @@ -/* -Profile topbar -Defines the profile topbar component -Markup: html/profile_topbar.html -Style guide profile_topbar -*/ - -.profile_topbar__column { - position: relative; - min-height: 160px; - height: 100%; - - .btn-collapse { - position: absolute; - bottom: 0; - margin-bottom: 0; - } -} - -.profile_topbar__expander { - background-color: map-get($ecl-colors, 'grey-10'); - overflow: hidden; -} diff --git a/framework/components/ecl-profile-topbars/ecl-profile-topbars.config.js b/framework/components/ecl-profile-topbars/ecl-profile-topbars.config.js index 1523e0a2b78..11e2925f05c 100644 --- a/framework/components/ecl-profile-topbars/ecl-profile-topbars.config.js +++ b/framework/components/ecl-profile-topbars/ecl-profile-topbars.config.js @@ -1,6 +1,60 @@ module.exports = { title: 'Profile topbars', label: 'Profile topbars', - status: 'planned', + status: 'ready', tags: ['organism'], + context: { + _demo: { + scripts: + "document.addEventListener('DOMContentLoaded', function () { ECL.initExpandables(); });", + }, + profile: { + image: { + src: 'http://lorempixel.com/output/business-q-c-160-160-10.jpg', + alt: 'Example profile image', + }, + expandable: { + button: { + label: 'See details', + extraClass: 'ecl-expandable__button ecl-profile-topbar__pane-button', + extraAttributes: [ + { + name: 'aria-controls', + value: 'ecl-profile-topbar__expandable-1', + }, + { name: 'aria-expanded', value: 'false' }, + { name: 'id', value: 'ecl-profile-topbar__expandable-button-1' }, + { name: 'type', value: 'button' }, + ], + }, + expandable_body: { + extraAttributes: [ + { + name: 'aria-hidden', + value: 'true', + }, + { + name: 'aria-labelledby', + value: 'ecl-profile-topbar__expandable-button-1', + }, + { name: 'id', value: 'ecl-profile-topbar__expandable-1' }, + { name: 'class', value: 'ecl-profile-topbar__collapsible-area' }, + ], + }, + }, + }, + context_nav: { + label: 'Department', + items: [ + { + target: '#', + title: 'Trade', + }, + { + target: '#', + title: ' European Anti-Fraud Office', + }, + ], + }, + }, }; diff --git a/framework/components/ecl-profile-topbars/ecl-profile-topbars.scss b/framework/components/ecl-profile-topbars/ecl-profile-topbars.scss new file mode 100644 index 00000000000..5a6c12bf0b5 --- /dev/null +++ b/framework/components/ecl-profile-topbars/ecl-profile-topbars.scss @@ -0,0 +1,26 @@ +/** + * ECL Profile Topbar + * @define profile-topbar + */ + +.ecl-profile-topbar { + margin: 0; + padding-bottom: map-get($ecl-spacing, 'm'); + padding-top: map-get($ecl-spacing, 'm'); +} + +.ecl-profile-topbar__pane { + height: 100%; + min-height: 160px; + position: relative; +} + +.ecl-profile-topbar__pane-button { + bottom: 0; + position: absolute; +} + +.ecl-profile-topbar__collapsible-area { + background-color: map-get($ecl-colors, 'grey-10'); + overflow: hidden; +} diff --git a/framework/components/ecl-profile-topbars/ecl-profile-topbars.twig b/framework/components/ecl-profile-topbars/ecl-profile-topbars.twig index 4e97a9ff380..c24ff19c9b7 100644 --- a/framework/components/ecl-profile-topbars/ecl-profile-topbars.twig +++ b/framework/components/ecl-profile-topbars/ecl-profile-topbars.twig @@ -1,31 +1,65 @@ -
- -
-
-
- -
- -
-
Department - -
- - -
-
-
+{# + Component interface: + - `extraClass` - classes to add to root component + - `extraAttributes` - additional attributes to add to root component + + - `context_nav` - data for @ec-europa/ecl-context-navs component composition + + - `profile` data contains profile-specific information + - `image` - data for @ec-europa/ecl-images component composition + - `expandable` - data related to the expandable part of the component + - `button` - data for @ec-europa/ecl-buttons component composition + - `expandable_body` - accepts `extraAttributes` for the expandable + + - body (block): content in the expandable area (default: lorem ipsum text) +#} + + +{# Internal properties #} -
-
- Expander content -
+{% set _cssClass = 'ecl-profile-topbar' %} +{% set _extraAttributes = '' %} + +{# Internal logic - Process properties #} + +{% if extraClass is defined %} + {% set _cssClass = _cssClass ~ ' ' ~ extraClass %} +{% endif %} + +{% if extraAttributes is defined %} + {% for attr in extraAttributes %} + {% set _extraAttributes = _extraAttributes ~ ' ' ~ attr.name ~ '="' ~ attr.value ~ '"' %} + {% endfor %} +{% endif %} + +{# Print result #} + +
+
+
+
+ {% include '@ec-europa/ecl-images' with profile.image %} +
+
+ {% include '@ec-europa/ecl-context-navs' with context_nav %} + {% include '@ec-europa/ecl-buttons' with profile.expandable.button %} +
+
+
+
+ {% block body %} +

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et augue quis est dignissim lacinia. Curabitur interdum iaculis sagittis. Maecenas sodales elit est, et suscipit nisl vulputate eget. Mauris vel pulvinar odio. Sed diam turpis, cursus vel congue vel, lobortis a ipsum. Donec vel quam nec enim tristique efficitur at eget nisl. +

+ {% endblock %} +
+
diff --git a/framework/components/ecl-profile-topbars/package.json b/framework/components/ecl-profile-topbars/package.json index 5dd2df9747e..26e2606fafd 100644 --- a/framework/components/ecl-profile-topbars/package.json +++ b/framework/components/ecl-profile-topbars/package.json @@ -1,15 +1,25 @@ { - "private": true, "name": "@ec-europa/ecl-profile-topbars", "version": "0.3.0", "description": "", - "main": "_profile-topbars.scss", - "style": "_profile-topbars.scss", + "main": "ecl-profile-topbars.scss", + "style": "ecl-profile-topbars.scss", "author": "European Commission", "license": "EUPL-1.1", "peerDependencies": { - "@ec-europa/ecl-buttons": "^0.1.0", - "@ec-europa/ecl-context-navs": "^0.1.0", - "@ec-europa/ecl-icons": "^0.1.0" - } + "@ec-europa/ecl-buttons": "^0.7.1", + "@ec-europa/ecl-context-navs": "^0.3.1", + "@ec-europa/ecl-icons": "^0.5.1" + }, + "publishConfig": { + "access": "public" + }, + "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#readme" } diff --git a/framework/components/ecl-profile-topbars/profile-topbars.js b/framework/components/ecl-profile-topbars/profile-topbars.js deleted file mode 100644 index 2f81286ef2e..00000000000 --- a/framework/components/ecl-profile-topbars/profile-topbars.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @file - * Breadcrumb related behaviors. - */ - -// eslint-disable-next-line import/prefer-default-export -export function profileTopbars() { - console.error('This script needs to be rewritten without jQuery'); -} diff --git a/framework/index.js b/framework/index.js index 7d42e4828eb..e4d07c5d242 100644 --- a/framework/index.js +++ b/framework/index.js @@ -20,4 +20,3 @@ export * from './components/ecl-navigation/ecl-navigation-menus/megamenu'; export * from './components/ecl-tables/ecl-tables'; export * from './components/ecl-tabs/tabs'; // export * from './components/ecl-timelines/timelines'; -// export * from './components/ecl-profile-topbars/profile-topbars'; diff --git a/test/functional/profile-toolbars.js b/test/functional/profile-toolbars.js new file mode 100644 index 00000000000..6523f0b4c41 --- /dev/null +++ b/test/functional/profile-toolbars.js @@ -0,0 +1,26 @@ +describe('profile-toolbars', () => { + before(() => { + // Set viewport size + browser.setViewportSize({ + width: 1400, + height: 600, + }); + + browser.pause(1000); + browser.url('ecl-profile-topbars.html'); + browser.injectAxeCore(); + }); + + // Normal state + it('should match the reference screenshot', () => { + const screenshots = browser.checkDocument({ + name: 'profile-toolbars', + }); + expect(screenshots).to.matchReference(); + }); + + it('should be accessible', () => { + const a11yReport = browser.runAxeCore('ecl-profile-topbar').value; + expect(a11yReport).to.be.accessible; + }); +}); diff --git a/test/screenshots/reference/profile-toolbars/OS X 10.11_Safari_v9.png b/test/screenshots/reference/profile-toolbars/OS X 10.11_Safari_v9.png new file mode 100644 index 00000000000..104e6acb4ae Binary files /dev/null and b/test/screenshots/reference/profile-toolbars/OS X 10.11_Safari_v9.png differ diff --git a/test/screenshots/reference/profile-toolbars/Windows 10_Chrome_v56.png b/test/screenshots/reference/profile-toolbars/Windows 10_Chrome_v56.png new file mode 100644 index 00000000000..32bf4890a10 Binary files /dev/null and b/test/screenshots/reference/profile-toolbars/Windows 10_Chrome_v56.png differ diff --git a/test/screenshots/reference/profile-toolbars/Windows 7_Firefox_v46.png b/test/screenshots/reference/profile-toolbars/Windows 7_Firefox_v46.png new file mode 100644 index 00000000000..18e1f59f3e6 Binary files /dev/null and b/test/screenshots/reference/profile-toolbars/Windows 7_Firefox_v46.png differ diff --git a/test/screenshots/reference/profile-toolbars/Windows 7_IE_v11.png b/test/screenshots/reference/profile-toolbars/Windows 7_IE_v11.png new file mode 100644 index 00000000000..bbd6b6e8748 Binary files /dev/null and b/test/screenshots/reference/profile-toolbars/Windows 7_IE_v11.png differ