-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(FluidDatePicker): add
FluidDatePickerSkeleton
variant (#12485)
* feat(FluidDatePicker): scaffold out initial react files * feat(FluidDatePicker): scaffold out more files * style(FluidDatePicker): add more styles for FluidDatePicker * style(FluidDatePicker): add single invalid styles * style(FluidDatePicker): clean up invalid, warn states on all variants * chore(storybook): fix playground, remove test examples * feat(FluidDatePicker): add FluidDatePickerSkeleton variant Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
acad2b8
commit 7ac1fa0
Showing
7 changed files
with
184 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
71 changes: 71 additions & 0 deletions
71
packages/react/src/components/FluidDatePicker/FluidDatePicker.Skeleton.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,71 @@ | ||
/** | ||
* Copyright IBM Corp. 2016, 2018 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import classnames from 'classnames'; | ||
import { usePrefix } from '../../internal/usePrefix'; | ||
import { FormContext } from '../FluidForm/FormContext'; | ||
import { Calendar } from '@carbon/icons-react'; | ||
|
||
function FluidDatePickerSkeleton({ | ||
className, | ||
datePickerType = 'single', | ||
...other | ||
}) { | ||
const prefix = usePrefix(); | ||
|
||
const classNames = classnames( | ||
className, | ||
`${prefix}--form-item ${prefix}--date-picker--fluid__skeleton`, | ||
{ | ||
[`${prefix}--date-picker--fluid__skeleton--range`]: | ||
datePickerType === 'range', | ||
} | ||
); | ||
|
||
return ( | ||
<FormContext.Provider value={{ isFluid: true }}> | ||
<div className={classNames} {...other}> | ||
<div className={`${prefix}--date-picker--fluid__skeleton--container`}> | ||
<span className={`${prefix}--label ${prefix}--skeleton`} /> | ||
<div className={`${prefix}--skeleton ${prefix}--text-input`} /> | ||
{datePickerType !== 'simple' && ( | ||
<Calendar | ||
className={`${prefix}--date-picker__icon`} | ||
role="img" | ||
aria-hidden="true"></Calendar> | ||
)} | ||
</div> | ||
{datePickerType === 'range' && ( | ||
<div className={`${prefix}--date-picker--fluid__skeleton--container`}> | ||
<span className={`${prefix}--label ${prefix}--skeleton`} /> | ||
<div className={`${prefix}--skeleton ${prefix}--text-input`} /> | ||
<Calendar | ||
className={`${prefix}--date-picker__icon`} | ||
role="img" | ||
aria-hidden="true"></Calendar> | ||
</div> | ||
)} | ||
</div> | ||
</FormContext.Provider> | ||
); | ||
} | ||
|
||
FluidDatePickerSkeleton.propTypes = { | ||
/** | ||
* Specify an optional className to be applied to the outer FluidForm wrapper | ||
*/ | ||
className: PropTypes.string, | ||
|
||
/** | ||
* Specify which variant of the DatePicker the skeleton should mimic | ||
*/ | ||
datePickerType: PropTypes.oneOf(['simple', 'single', 'range']), | ||
}; | ||
|
||
export default FluidDatePickerSkeleton; |
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
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