-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Components: promote
Scrollable
(#32446)
* Move `Scrollable` to `src` folder, update import paths * Add `Scrollable` to `tsconfig.json` * Add `Scrollable`'s README to list of docs * Scrollable: add smoothScroll and scrollDirection to storybook story
- Loading branch information
Showing
14 changed files
with
106 additions
and
31 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
4 changes: 2 additions & 2 deletions
4
...components/src/ui/scrollable/component.js → ...es/components/src/scrollable/component.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
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
File renamed without changes.
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,82 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { boolean, select } from '@storybook/addon-knobs'; | ||
/* eslint-disable-next-line no-restricted-imports */ | ||
import React from 'react'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { View } from '../../view'; | ||
import { Scrollable } from '../'; | ||
|
||
export default { | ||
component: Scrollable, | ||
title: 'Components (Experimental)/Scrollable', | ||
}; | ||
|
||
export const _default = () => { | ||
const targetRef = React.useRef( null ); | ||
|
||
const onButtonClick = () => { | ||
targetRef.current?.focus(); | ||
}; | ||
|
||
const otherProps = { | ||
smoothScroll: boolean( | ||
'Scrollable: smoothScroll (hint: move focus in the scrollable container)', | ||
false | ||
), | ||
scrollDirection: select( | ||
'Scrollable: scrollDirection', | ||
{ | ||
x: 'x', | ||
y: 'y', | ||
auto: 'auto', | ||
}, | ||
'y' | ||
), | ||
}; | ||
|
||
const containerWidth = 300; | ||
const containerHeight = 400; | ||
|
||
return ( | ||
<Scrollable | ||
style={ { height: containerHeight, width: containerWidth } } | ||
{ ...otherProps } | ||
> | ||
<View | ||
style={ { | ||
backgroundColor: '#eee', | ||
height: | ||
otherProps.scrollDirection === 'x' | ||
? containerHeight | ||
: 1000, | ||
width: | ||
otherProps.scrollDirection === 'y' | ||
? containerWidth | ||
: 1000, | ||
position: 'relative', | ||
} } | ||
> | ||
<button onClick={ onButtonClick }> | ||
Move focus to an element out of view | ||
</button> | ||
<input | ||
ref={ targetRef } | ||
style={ { | ||
position: 'absolute', | ||
bottom: | ||
otherProps.scrollDirection === 'x' ? 'initial' : 0, | ||
right: | ||
otherProps.scrollDirection === 'y' ? 'initial' : 0, | ||
} } | ||
type="text" | ||
value="Focus me" | ||
/> | ||
</View> | ||
</Scrollable> | ||
); | ||
}; |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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.
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