-
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.
Merge branch 'dsfr-plus' into staging
- Loading branch information
Showing
39 changed files
with
2,867 additions
and
1,206 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
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,79 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import classNames from 'classnames'; | ||
|
||
// import '@gouvfr/dsfr/dist/component/link/link.css'; | ||
|
||
const getAll = (props) => { | ||
const newProps = {}; | ||
|
||
Object.keys(props).forEach((key) => { | ||
if (key.startsWith('data-') || key === 'id') { | ||
newProps[key] = props[key]; | ||
} | ||
}); | ||
|
||
return newProps; | ||
}; | ||
|
||
function File({ | ||
className, | ||
label, | ||
errorMessage, | ||
hint, | ||
onChange, | ||
multiple, | ||
accept, | ||
...remainingProps | ||
}) { | ||
const _className = classNames( | ||
'fr-upload-group', | ||
className, | ||
{ | ||
[`ds-fr--${label}`]: label, | ||
}, | ||
); | ||
|
||
return ( | ||
<div {...getAll(remainingProps)} className={_className}> | ||
<label className="fr-label" htmlFor="file-upload"> | ||
{label} | ||
{hint && <p className="fr-hint-text">{hint}</p>} | ||
</label> | ||
<input | ||
onChange={onChange} | ||
className="fr-upload" | ||
type="file" | ||
aria-describedby={hint || undefined} | ||
multiple={multiple} | ||
accept={accept} | ||
/> | ||
{errorMessage && ( | ||
<p id="file-upload-with-error-desc-error" className="fr-error-text"> | ||
{errorMessage} | ||
</p> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
File.defaultProps = { | ||
className: '', | ||
hint: '', | ||
errorMessage: '', | ||
accept: undefined, | ||
multiple: false, | ||
onChange: () => { }, | ||
}; | ||
|
||
File.propTypes = { | ||
className: PropTypes.string, | ||
label: PropTypes.string.isRequired, | ||
multiple: PropTypes.bool, | ||
onChange: PropTypes.func, | ||
errorMessage: PropTypes.string, | ||
hint: PropTypes.string, | ||
accept: PropTypes.string, | ||
}; | ||
|
||
export default File; |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.