Skip to content

Commit 773c1d4

Browse files
committed
docs: add scaled css demo, add type defs to prop stories
1 parent 890a97c commit 773c1d4

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

docs/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-env node */
12
module.exports = {
23
rules: {
34
'no-console': 0,

docs/05-only-handle-draggable.story.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs/blocks';
22

33
import { ReactCompareSlider, ReactCompareSliderImage } from 'react-compare-slider';
44

5-
import { BlurredArrows } from './demos/02-handles.story';
6-
75
<Meta title="Docs/Only Handle Draggable" component={ReactCompareSlider} />
86

97
# Using `onlyHandleDraggable`

docs/demos/00-props.story.tsx

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint no-console: 0 */
22
import React from 'react';
3+
import { Story } from '@storybook/react';
34

45
import { ReactCompareSlider, ReactCompareSliderImage } from 'react-compare-slider';
56

@@ -11,7 +12,7 @@ export default {
1112
argTypes: config.argTypes,
1213
};
1314

14-
export const Images = (props) => (
15+
export const Images: Story = (props) => (
1516
<ReactCompareSlider
1617
{...props}
1718
itemOne={
@@ -33,7 +34,7 @@ export const Images = (props) => (
3334

3435
Images.args = { boundsPadding: 0 };
3536

36-
export const BoundsPadding = ({ boundsPadding = 80, ...props }) => {
37+
export const BoundsPadding: Story = ({ boundsPadding = 80, ...props }) => {
3738
return (
3839
<div style={{ display: 'flex', flexDirection: 'column', flexGrow: 1 }}>
3940
<ReactCompareSlider
@@ -59,7 +60,7 @@ export const BoundsPadding = ({ boundsPadding = 80, ...props }) => {
5960

6061
BoundsPadding.args = { boundsPadding: 80 };
6162

62-
export const OnPositionChange = (props) => {
63+
export const OnPositionChange: Story = (props) => {
6364
const onPositionChange = React.useCallback((position) => {
6465
console.log('[OnPositionChange.onPositionChange]', position);
6566
}, []);
@@ -95,7 +96,7 @@ export const OnPositionChange = (props) => {
9596

9697
OnPositionChange.args = { boundsPadding: 0 };
9798

98-
export const OnlyHandleDraggable = ({ onlyHandleDraggable = true, ...props }) => {
99+
export const OnlyHandleDraggable: Story = ({ onlyHandleDraggable = true, ...props }) => {
99100
return (
100101
<div style={{ display: 'flex', flexDirection: 'column', flexGrow: 1 }}>
101102
<ReactCompareSlider
@@ -122,7 +123,7 @@ export const OnlyHandleDraggable = ({ onlyHandleDraggable = true, ...props }) =>
122123

123124
OnlyHandleDraggable.args = { boundsPadding: 0, onlyHandleDraggable: true };
124125

125-
export const Portrait = ({ portrait = true, ...props }) => (
126+
export const Portrait: Story = ({ portrait = true, ...props }) => (
126127
<ReactCompareSlider
127128
portrait={portrait}
128129
itemOne={
@@ -145,7 +146,7 @@ export const Portrait = ({ portrait = true, ...props }) => (
145146

146147
Portrait.args = { boundsPadding: 0, portrait: true };
147148

148-
export const Position = ({ position = 75, ...props }) => (
149+
export const Position: Story = ({ position = 75, ...props }) => (
149150
<ReactCompareSlider
150151
position={position}
151152
itemOne={
@@ -169,7 +170,10 @@ export const Position = ({ position = 75, ...props }) => (
169170

170171
Position.args = { boundsPadding: 0, position: 25 };
171172

172-
export const ChangePositionOnHover = ({ changePositionOnHover = true, ...props }) => {
173+
export const ChangePositionOnHover: Story = ({
174+
changePositionOnHover = true,
175+
...props
176+
}) => {
173177
return (
174178
<div style={{ display: 'flex', flexDirection: 'column', flexGrow: 1 }}>
175179
<ReactCompareSlider
@@ -195,3 +199,29 @@ export const ChangePositionOnHover = ({ changePositionOnHover = true, ...props }
195199
};
196200

197201
ChangePositionOnHover.args = { boundsPadding: 0, changePositionOnHover: true };
202+
203+
export const Scaled: Story = ({ style, ...props }) => (
204+
<ReactCompareSlider
205+
{...props}
206+
itemOne={
207+
<ReactCompareSliderImage
208+
src="https://images.unsplash.com/photo-1580458148391-8c4951dc1465?auto=format&fit=crop&w=1280&q=80"
209+
style={{ filter: 'grayscale(1)' }}
210+
alt="one"
211+
/>
212+
}
213+
itemTwo={
214+
<ReactCompareSliderImage
215+
src="https://images.unsplash.com/photo-1580458148391-8c4951dc1465?auto=format&fit=crop&w=1280&q=80"
216+
alt="two"
217+
/>
218+
}
219+
style={{ width: '100%', height: '100vh', ...style }}
220+
/>
221+
);
222+
223+
Scaled.args = {
224+
style: {
225+
transform: 'scale(0.75)',
226+
},
227+
};

0 commit comments

Comments
 (0)