-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(eu-header): apply new specs - INNO-1203 #811
Changes from 7 commits
1454e4e
78d15dd
9f511eb
c08d7e5
ac0f9b2
91ac880
7bc1d5e
199a729
ce48c6b
acbfaff
e4f4a90
9371003
5ea3799
f659129
ceb628b
e7a1f91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import classnames from 'classnames'; | ||
|
||
import Icon from '@ecl/eu-react-component-icon/Icon'; | ||
import Logo from '@ecl/eu-react-component-logo/Logo'; | ||
import SearchForm from '@ecl/eu-react-component-search-form/SearchForm'; | ||
|
||
const SiteHeader = ({ | ||
logo, | ||
languageSelector, | ||
searchForm, | ||
className, | ||
...props | ||
}) => { | ||
const classNames = classnames(className, { | ||
'ecl-site-header': true, | ||
}); | ||
|
||
return ( | ||
<div className={classNames} {...props}> | ||
<div className="ecl-site-header__container ecl-container"> | ||
<div className="ecl-site-header__banner"> | ||
<a | ||
className="ecl-site-header__logo ecl-link ecl-link--standalone" | ||
href={logo.href} | ||
> | ||
<Logo title={logo.title} alt={logo.alt} language={logo.language} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not |
||
</a> | ||
|
||
<div className="ecl-site-header__selector"> | ||
<a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because Link do not allow anything else from simple text for now |
||
className="ecl-link ecl-link--standalone" | ||
href={languageSelector.href} | ||
> | ||
{languageSelector.name} | ||
<span className="ecl-site-header__language-icon"> | ||
<Icon icon="Icon_Language" size="m" /> | ||
<span className="ecl-site-header__language-code"> | ||
{languageSelector.code} | ||
</span> | ||
</span> | ||
</a> | ||
</div> | ||
</div> | ||
|
||
<SearchForm | ||
className="ecl-site-header__search" | ||
buttonLabel={searchForm.buttonLabel} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not |
||
textInputId={searchForm.textInputId} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
SiteHeader.propTypes = { | ||
logo: PropTypes.shape({ | ||
title: PropTypes.string, | ||
alt: PropTypes.string, | ||
language: PropTypes.string, | ||
href: PropTypes.string, | ||
}), | ||
languageSelector: PropTypes.shape({ | ||
href: PropTypes.string, | ||
name: PropTypes.string, | ||
code: PropTypes.string, | ||
}), | ||
searchForm: PropTypes.shape({ | ||
textInputId: PropTypes.string, | ||
buttonLabel: PropTypes.string, | ||
}), | ||
className: PropTypes.string, | ||
}; | ||
|
||
SiteHeader.defaultProps = { | ||
logo: { | ||
title: '', | ||
alt: '', | ||
language: '', | ||
href: '#', | ||
}, | ||
languageSelector: { | ||
href: '#', | ||
name: '', | ||
code: '', | ||
}, | ||
searchForm: { | ||
textInputId: '', | ||
buttonLabel: '', | ||
}, | ||
className: '', | ||
}; | ||
|
||
export default SiteHeader; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"name": "@ecl/eu-react-component-site-header", | ||
"author": "European Commission", | ||
"license": "EUPL-1.1", | ||
"version": "2.0.0-alpha.0", | ||
"description": "ECL EC React Site Header", | ||
"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", | ||
"keywords": [ | ||
"ecl", | ||
"europa-component-library", | ||
"design-system", | ||
"react" | ||
], | ||
"dependencies": { | ||
"@ecl/eu-layout-grid": "^2.0.0-alpha.0", | ||
"@ecl/eu-react-component-icon": "^2.0.0-alpha.0", | ||
"@ecl/eu-react-component-logo": "^2.0.0-alpha.0", | ||
"@ecl/eu-react-component-search-form": "^2.0.0-alpha.0" | ||
}, | ||
"devDependencies": { | ||
"@ecl/eu-resources": "^2.0.0-alpha.0", | ||
"@ecl/eu-specs-site-header": "^2.0.0-alpha.0" | ||
}, | ||
"peerDependencies": { | ||
"classnames": "^2.2.6", | ||
"react": "^16.4.2", | ||
"react-dom": "^16.4.2", | ||
"prop-types": "^15.6.2" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { withKnobs } from '@storybook/addon-knobs/react'; | ||
|
||
import demoContent from '@ecl/eu-specs-site-header/demo/data'; | ||
|
||
import SiteHeader from '../SiteHeader'; | ||
|
||
storiesOf('SiteHeader', module) | ||
.addDecorator(withKnobs) | ||
.add('default', () => ( | ||
<SiteHeader | ||
logo={demoContent.logo} | ||
languageSelector={demoContent.languageSelector} | ||
searchForm={demoContent.searchForm} | ||
/> | ||
)); |
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = { | ||
logo: { | ||
href: '/example', | ||
}, | ||
languageSelector: { | ||
href: '/example', | ||
name: 'English', | ||
code: 'en', | ||
}, | ||
searchForm: { | ||
textInputId: '', | ||
buttonLabel: 'Search', | ||
}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use
<header>
? androle="banner"
?https://www.w3.org/TR/wai-aria-practices-1.1/examples/landmarks/banner.html
https://www.scottohara.me/blog/2018/03/03/landmarks.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
role="banner"
is reported as an error by a11y, but indeed it should be header and not div