-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from uber-web/master
feat(bidi): add rtl support
- Loading branch information
Showing
17 changed files
with
1,133 additions
and
1,032 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
import '@storybook/addon-options/register'; | ||
import 'storybook-addon-rtl/register'; |
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
Binary file added
BIN
+2.05 KB
e2e/__image_snapshots__/rtl-test-ts-dnd-the-thumb-to-right-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,30 @@ | ||
import { | ||
Examples, | ||
getTestUrl, | ||
trackMouse, | ||
untrackMouse, | ||
addFontStyles | ||
} from './utils'; | ||
|
||
jest.setTimeout(10000); | ||
|
||
beforeEach(async () => { | ||
await page.goto(getTestUrl(Examples.RTL)); | ||
await page.setViewport({ width: 600, height: 200 }); | ||
await addFontStyles(page); | ||
await page.evaluate(() => { | ||
document.dir = 'rtl'; | ||
}) | ||
}); | ||
|
||
test('dnd the thumb to right', async () => { | ||
await trackMouse(page); | ||
await page.mouse.move(300, 80); | ||
await page.mouse.down(); | ||
await page.mouse.move(460, 80); | ||
await page.mouse.up(); | ||
await untrackMouse(page); | ||
const output = await page.$('#output'); | ||
expect(await page.evaluate(e => e.textContent, output)).toBe('20.4'); | ||
expect(await page.screenshot()).toMatchImageSnapshot(); | ||
}); |
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,92 @@ | ||
import * as React from 'react'; | ||
import { Range, getTrackBackground } from '../src/index'; | ||
|
||
const STEP = 0.1; | ||
const MIN = 0; | ||
const MAX = 100; | ||
|
||
class Basic extends React.Component { | ||
state = { | ||
values: [50] | ||
}; | ||
render() { | ||
return ( | ||
<div | ||
style={{ | ||
display: 'flex', | ||
justifyContent: 'center', | ||
flexWrap: 'wrap' | ||
}} | ||
> | ||
<Range | ||
values={this.state.values} | ||
step={STEP} | ||
min={MIN} | ||
max={MAX} | ||
rtl | ||
onChange={values => this.setState({ values })} | ||
renderTrack={({ props, children }) => ( | ||
<div | ||
onMouseDown={props.onMouseDown} | ||
onTouchStart={props.onTouchStart} | ||
style={{ | ||
...props.style, | ||
height: '36px', | ||
display: 'flex', | ||
width: '100%' | ||
}} | ||
> | ||
<div | ||
ref={props.ref} | ||
style={{ | ||
height: '5px', | ||
width: '100%', | ||
borderRadius: '4px', | ||
background: getTrackBackground({ | ||
values: this.state.values, | ||
colors: ['#548BF4', '#ccc'], | ||
min: MIN, | ||
max: MAX, | ||
rtl: true, | ||
}), | ||
alignSelf: 'center' | ||
}} | ||
> | ||
{children} | ||
</div> | ||
</div> | ||
)} | ||
renderThumb={({ props, isDragged }) => ( | ||
<div | ||
{...props} | ||
style={{ | ||
...props.style, | ||
height: '42px', | ||
width: '42px', | ||
borderRadius: '4px', | ||
backgroundColor: '#FFF', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
boxShadow: '0px 2px 6px #AAA' | ||
}} | ||
> | ||
<div | ||
style={{ | ||
height: '16px', | ||
width: '5px', | ||
backgroundColor: isDragged ? '#548BF4' : '#CCC' | ||
}} | ||
/> | ||
</div> | ||
)} | ||
/> | ||
<output style={{ marginTop: '30px' }} id="output"> | ||
{this.state.values[0].toFixed(1)} | ||
</output> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default Basic; |
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,94 @@ | ||
import * as React from 'react'; | ||
import { Range, getTrackBackground } from '../src/index'; | ||
|
||
const STEP = 0.1; | ||
const MIN = 0; | ||
const MAX = 100; | ||
|
||
class TwoThumbs extends React.Component { | ||
state = { | ||
values: [25, 75] | ||
}; | ||
render() { | ||
return ( | ||
<div | ||
style={{ | ||
display: 'flex', | ||
justifyContent: 'center', | ||
flexWrap: 'wrap' | ||
}} | ||
> | ||
<Range | ||
values={this.state.values} | ||
step={STEP} | ||
min={MIN} | ||
max={MAX} | ||
rtl | ||
onChange={values => { | ||
this.setState({ values }) | ||
}} | ||
renderTrack={({ props, children }) => ( | ||
<div | ||
onMouseDown={props.onMouseDown} | ||
onTouchStart={props.onTouchStart} | ||
style={{ | ||
...props.style, | ||
height: '36px', | ||
display: 'flex', | ||
width: '100%' | ||
}} | ||
> | ||
<div | ||
ref={props.ref} | ||
style={{ | ||
height: '5px', | ||
width: '100%', | ||
borderRadius: '4px', | ||
background: getTrackBackground({ | ||
values: this.state.values, | ||
colors: ['#ccc', '#548BF4', '#ccc'], | ||
min: MIN, | ||
max: MAX, | ||
rtl: true, | ||
}), | ||
alignSelf: 'center' | ||
}} | ||
> | ||
{children} | ||
</div> | ||
</div> | ||
)} | ||
renderThumb={({ props, isDragged }) => ( | ||
<div | ||
{...props} | ||
style={{ | ||
...props.style, | ||
height: '42px', | ||
width: '42px', | ||
borderRadius: '4px', | ||
backgroundColor: '#FFF', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
boxShadow: '0px 2px 6px #AAA' | ||
}} | ||
> | ||
<div | ||
style={{ | ||
height: '16px', | ||
width: '5px', | ||
backgroundColor: isDragged ? '#548BF4' : '#CCC' | ||
}} | ||
/> | ||
</div> | ||
)} | ||
/> | ||
<output style={{ marginTop: '30px' }} id="output"> | ||
{this.state.values[0].toFixed(1)} - {this.state.values[1].toFixed(1)} | ||
</output> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default TwoThumbs; |
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
Oops, something went wrong.