-
Notifications
You must be signed in to change notification settings - Fork 103
feat(Loader): Initial Implementation #153
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4638365
fix(FilterBar): Added scrolling and wrapping for small screens
Lukas742 55a55ac
fix(FilterBar): Replaced width:100% with flexGrow
Lukas742 577a16b
fix(FilterBar): overflow-y
Lukas742 66333bc
feat(Loader): Added Loader component.
Lukas742 2a83dcf
Merge branch 'master' into feature/Loader
Lukas742 fe4b5e6
Merge branch 'master' into feature/Loader
Lukas742 d7982f6
Merge branch 'feature/Loader' of github.com:SAP/ui5-webcomponents-rea…
Lukas742 e619f6a
Update packages/main/src/components/Loader/index.tsx
Lukas742 59d6981
Merge branch 'feature/Loader' of github.com:SAP/ui5-webcomponents-rea…
Lukas742 f6acda7
feat(Loader): Test description and requested changes
Lukas742 cce2770
Merge branch 'master' into feature/Loader
MarcusNotheis d3a23a4
WIP: Change Style Memoization
MarcusNotheis b9b643c
WIP: Added Tests
MarcusNotheis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,36 @@ | ||
import { JSSTheme } from '../../interfaces/JSSTheme'; | ||
|
||
export const styles = ({ parameters }: JSSTheme) => ({ | ||
'@keyframes scroll': { | ||
'0%': { backgroundPosition: '-100% 0' }, | ||
'100%': { backgroundPosition: '200% 0' } | ||
}, | ||
|
||
loader: { | ||
height: '0.25rem', | ||
width: '100%', | ||
'&$loaderDeterminate': { | ||
background: `linear-gradient(to right, ${parameters.sapUiContentIconColor}, ${parameters.sapUiContentIconColor})`, | ||
backgroundColor: 'rgba(8, 84, 160, 0.15)', | ||
backgroundSize: (props) => props.progressBarWidth, | ||
backgroundRepeat: 'repeat-y' | ||
}, | ||
'&$loaderIndeterminate': { | ||
background: `linear-gradient( | ||
to right, | ||
rgba(8, 84, 160, 0) 0px, | ||
rgba(8, 84, 160, 1) calc(50% - 2rem), | ||
${parameters.sapUiContentIconColor} calc(50% - 2rem), | ||
${parameters.sapUiContentIconColor} calc(50% + 2rem), | ||
rgba(8, 84, 160, 1) calc(50% + 2rem), | ||
rgba(8, 84, 160, 0) 100% | ||
)`, | ||
backgroundColor: 'rgba(8, 84, 160, 0.15)', | ||
backgroundSize: '40%', | ||
backgroundRepeat: 'repeat-y', | ||
animation: '$scroll 1.2s linear infinite' | ||
} | ||
}, | ||
loaderDeterminate: {}, | ||
loaderIndeterminate: {} | ||
}); |
This file contains hidden or 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,26 @@ | ||
import { renderThemedComponent } from '@shared/tests/utils'; | ||
import React from 'react'; | ||
import { LoaderType } from '@ui5/webcomponents-react/lib/LoaderType'; | ||
import { Loader } from '@ui5/webcomponents-react/lib/Loader'; | ||
|
||
describe('Loader', () => { | ||
test('small', () => { | ||
const wrapper = renderThemedComponent(<Loader type={LoaderType.Indeterminate} />); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
test('medium', () => { | ||
const wrapper = renderThemedComponent(<Loader type={LoaderType.Determinate} />); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
test('large', () => { | ||
const wrapper = renderThemedComponent(<Loader type={LoaderType.Determinate} progressBarWidth="42%" />); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
test('with custom class name', () => { | ||
const wrapper = renderThemedComponent(<Loader />); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
}); |
41 changes: 41 additions & 0 deletions
41
packages/main/src/components/Loader/__snapshots__/Loader.test.tsx.snap
This file contains hidden or 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,41 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Loader large 1`] = ` | ||
<div | ||
aria-busy="true" | ||
class="Loader--loader- Loader--loader-0- Loader--loaderDeterminate-" | ||
data-component-name="Loader" | ||
role="progressbar" | ||
title="Please wait" | ||
/> | ||
`; | ||
|
||
exports[`Loader medium 1`] = ` | ||
<div | ||
aria-busy="true" | ||
class="Loader--loader- Loader--loader-0- Loader--loaderDeterminate-" | ||
data-component-name="Loader" | ||
role="progressbar" | ||
title="Please wait" | ||
/> | ||
`; | ||
|
||
exports[`Loader small 1`] = ` | ||
<div | ||
aria-busy="true" | ||
class="Loader--loader- Loader--loader-0- Loader--loaderIndeterminate-" | ||
data-component-name="Loader" | ||
role="progressbar" | ||
title="Please wait" | ||
/> | ||
`; | ||
|
||
exports[`Loader with custom class name 1`] = ` | ||
<div | ||
aria-busy="true" | ||
class="Loader--loader- Loader--loader-0- Loader--loaderIndeterminate-" | ||
data-component-name="Loader" | ||
role="progressbar" | ||
title="Please wait" | ||
/> | ||
`; |
This file contains hidden or 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,19 @@ | ||
import { select, text } from '@storybook/addon-knobs'; | ||
import React from 'react'; | ||
import { Loader } from '@ui5/webcomponents-react/lib/Loader'; | ||
import { LoaderType } from '@ui5/webcomponents-react/lib/LoaderType'; | ||
|
||
export const renderLoader = () => ( | ||
<Loader | ||
type={select('type', LoaderType, LoaderType.Indeterminate)} | ||
progressBarWidth={text('progressBarWidth', '40%')} | ||
/> | ||
); | ||
renderLoader.story = { | ||
name: 'Default' | ||
}; | ||
|
||
export default { | ||
title: 'Components | Loader', | ||
component: Loader | ||
}; |
This file contains hidden or 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 { StyleClassHelper } from '@ui5/webcomponents-react-base/lib/StyleClassHelper'; | ||
import React, { forwardRef, RefObject, FC, CSSProperties } from 'react'; | ||
import { createUseStyles } from 'react-jss'; | ||
import { CommonProps } from '../../interfaces/CommonProps'; | ||
import { LoaderType } from '@ui5/webcomponents-react/lib/LoaderType'; | ||
import { styles } from './Loader.jss'; | ||
|
||
export interface LoaderProps extends CommonProps { | ||
type?: LoaderType; | ||
progressBarWidth?: CSSProperties['width']; | ||
} | ||
|
||
const useStyles = createUseStyles(styles, { name: 'Loader' }); | ||
Lukas742 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const Loader: FC<LoaderProps> = forwardRef((props: LoaderProps, ref: RefObject<HTMLDivElement>) => { | ||
const { className, type, progressBarWidth, tooltip, slot, style } = props; | ||
const classes = useStyles(props); | ||
|
||
const loaderClasses = StyleClassHelper.of(classes.loader); | ||
if (className) { | ||
loaderClasses.put(className); | ||
} | ||
loaderClasses.put(classes[`loader${type}`]); | ||
|
||
Lukas742 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return ( | ||
<div | ||
ref={ref} | ||
className={loaderClasses.valueOf()} | ||
data-component-name="Loader" | ||
aria-busy="true" | ||
role="progressbar" | ||
title={tooltip || 'Please wait'} | ||
slot={slot} | ||
style={style} | ||
/> | ||
); | ||
}); | ||
|
||
Loader.defaultProps = { | ||
type: LoaderType.Indeterminate, | ||
progressBarWidth: '0px' | ||
Lukas742 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
Loader.displayName = 'Loader'; | ||
|
||
export { Loader }; |
This file contains hidden or 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,4 @@ | ||
export enum LoaderType { | ||
Determinate = 'Determinate', | ||
Indeterminate = 'Indeterminate' | ||
} |
This file contains hidden or 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 hidden or 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,3 @@ | ||
import { Loader } from '../components/Loader'; | ||
|
||
export { Loader }; |
This file contains hidden or 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,3 @@ | ||
import { LoaderType } from '../enums/LoaderType'; | ||
|
||
export { LoaderType }; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.