Skip to content

Commit

Permalink
chore: migrate all components
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraghazra committed Nov 6, 2020
1 parent cda4960 commit efbe598
Show file tree
Hide file tree
Showing 20 changed files with 87 additions and 459 deletions.
4 changes: 1 addition & 3 deletions src/breadcrumbs/stories/Breadcrumbs.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import * as React from "react";

import { Breadcrumbs, BreadcrumbLink } from "renderless-components";

export interface AppProps {}

export const App: React.FC<AppProps> = props => {
export const App: React.FC = props => {
return (
<Breadcrumbs className="breadcrumb">
<ol>
Expand Down
47 changes: 7 additions & 40 deletions src/meter/stories/Meter.component.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import * as React from "react";
import { css, keyframes } from "emotion";

import { Meter, useMeterState, MeterStateReturn } from "renderless-components";
import {
Meter,
useMeterState,
MeterStateReturn,
MeterInitialState,
} from "renderless-components";

export interface AppProps {
export interface AppProps extends MeterInitialState {
/**
* Adds a label to meter.
* @default false
Expand All @@ -19,44 +24,6 @@ export interface AppProps {
* @default false
*/
withStripeAnimation?: boolean;
/**
* The `value` of the meter indicator.
*
* If `undefined`/`not valid` the meter bar will be equal to `min`
* @default 0
*/
value?: number;
/**
* The minimum value of the meter
* @default 0
*/
min?: number;
/**
* The maximum value of the meter
* @default 1
*/
max?: number;
/**
* The higher limit of min range.
*
* Defaults to `min`.
* @default 0
*/
low?: number;
/**
* The lower limit of max range.
*
* Defaults to `max`.
* @default 1
*/
high?: number;
/**
* The lower limit of max range.
*
* Defaults to `median of low & high`.
* @default 0.5
*/
optimum?: number;
}

export const App: React.FC<AppProps> = props => {
Expand Down
52 changes: 2 additions & 50 deletions src/number-input/stories/NumberInput.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,12 @@ import * as React from "react";
import {
NumberInput,
useNumberInputState,
NumberinputInitialState,
NumberInputDecrementButton,
NumberInputIncrementButton,
} from "renderless-components";

export interface AppProps {
/**
* The value of the counter. Should be less than `max` and greater than `min`
*
* If no value, initial value is set to `""`
*/
value?: string | number;
/**
* The minimum value of the counter
*
* @default Number.MIN_SAFE_INTEGER
*/
min?: number;
/**
* The maximum value of the counter
*
* @default Number.MAX_SAFE_INTEGER
*/
max?: number;
/**
* The step used to increment or decrement the value
*
* @default 1
*/
step?: number;
/**
* The number of decimal points used to round the value
*
* If no precision, initial value is from the decimal places
* from value/step - `0`
*/
precision?: number;
/**
* This controls the value update behavior in general.
*
* - If `true` and you use the stepper or up/down arrow keys,
* the value will not exceed the `max` or go lower than `min`
*
* - If `false`, the value will be allowed to go out of range.
*
* @default true
*/
keepWithinRange?: boolean;
/**
* If `true`, the input will be focused as you increment
* or decrement the value with the stepper
*
* @default true
*/
focusInputOnChange?: boolean;
export interface AppProps extends NumberinputInitialState {
/**
* This controls the value update when you blur out of the input.
* - If `true` and the value is greater than `max`, the value will be reset to `max`
Expand Down
24 changes: 4 additions & 20 deletions src/progress/stories/CircularProgress.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,19 @@ import { Button } from "reakit";
import { css, keyframes } from "emotion";

import {
isNull,
Progress,
useProgressState,
ProgressState,
isNull,
useProgressState,
ProgressInitialState,
} from "renderless-components";

export interface AppProps {
export interface AppProps extends ProgressInitialState {
/**
* Adds a label to meter.
* @default false
*/
withLabel?: boolean;
/**
* The `value` of the progress indicator.
*
* If `null` the progress bar will be in `indeterminate` state
* @default 0
*/
value?: number | null;
/**
* The minimum value of the progress
* @default 0
*/
min?: number;
/**
* The maximum value of the
* @default 100
*/
max?: number;
}

export const App: React.FC<AppProps> = props => {
Expand Down
2 changes: 1 addition & 1 deletion src/progress/stories/CircularProgress.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { createPreviewTabs } from "../../../scripts/create-preview-tabs";

export default {
component: Progress,
title: "ProgressCircular",
title: "Progress/Circular",
parameters: {
preview: createPreviewTabs({
js: circularProgressTemplateJs,
Expand Down
28 changes: 4 additions & 24 deletions src/progress/stories/LinearProgress.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,15 @@ import { Button } from "reakit";
import { css, keyframes } from "emotion";

import {
cx,
Progress,
useProgressState,
ProgressState,
cx,
useProgressState,
ProgressInitialState,
} from "renderless-components";
import { isNull } from "renderless-components/utils";

export interface AppProps {
/**
* The `value` of the progress indicator.
*
* If `null` the progress bar will be in `indeterminate` state
* @default 0
*/
value?: number | null;
/**
* The minimum value of the progress
* @default 0
*/
min?: number;
/**
* The maximum value of the
* @default 100
*/
max?: number;
/**
* Adds a label to meter.
* @default false
*/
export interface AppProps extends ProgressInitialState {
withLabel?: boolean;
/**
* Adds a stripe style to meter bar.
Expand Down
2 changes: 1 addition & 1 deletion src/progress/stories/LinearProgress.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { createPreviewTabs } from "../../../scripts/create-preview-tabs";

export default {
component: Progress,
title: "ProgressLinear",
title: "Progress/Linear",
parameters: {
preview: createPreviewTabs({
js: linearProgressTemplateJs,
Expand Down
4 changes: 1 addition & 3 deletions src/segment/stories/Segment.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import {
SegmentStateProps,
} from "renderless-components";

interface AppProps extends SegmentStateProps {}

export const App: React.FC<AppProps> = props => {
export const App: React.FC<SegmentStateProps> = props => {
const state = useSegmentState(props);

return (
Expand Down
8 changes: 1 addition & 7 deletions src/select/stories/Combobox.component.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from "react";
import { CompositeInitialState, PopoverInitialState } from "reakit";
import {
Select,
SelectMenu,
Expand All @@ -26,12 +25,7 @@ const countries = [
{ name: "zimbabwe", emoji: "🇿🇼" },
];

type AppProps = Omit<
SelectInitialState,
keyof (PopoverInitialState & CompositeInitialState)
>;

export const App: React.FC<AppProps> = props => {
export const App: React.FC<SelectInitialState> = props => {
const state = useSelectState({
...props,
allowMultiselect: true,
Expand Down
15 changes: 9 additions & 6 deletions src/select/stories/Combobox.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import { Meta, Story } from "@storybook/react";
import { Meta } from "@storybook/react";
import { PopoverInitialState, CompositeInitialState } from "reakit";

import {
selectCssTemplate,
Expand All @@ -14,10 +15,16 @@ import {
SelectInput,
SelectOption,
useSelectState,
SelectInitialState,
} from "..";

export const Default: React.FC<Omit<
SelectInitialState,
keyof (PopoverInitialState & CompositeInitialState)
>> = props => <Combobox {...props} />;

export default {
component: Combobox,
component: Default,
title: "Select/Combobox",
parameters: {
preview: createPreviewTabs({
Expand Down Expand Up @@ -45,10 +52,6 @@ const countries = [
{ name: "zimbabwe", emoji: "🇿🇼" },
];

const Base: Story = args => <Combobox {...args} />;

export const Default = Base.bind({});

export const WithoutFilter: React.FC = () => {
const state = useSelectState({
allowMultiselect: true,
Expand Down
8 changes: 1 addition & 7 deletions src/select/stories/Select.component.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from "react";
import { CompositeInitialState, PopoverInitialState } from "reakit";
import {
Select,
SelectMenu,
Expand All @@ -26,12 +25,7 @@ const countries = [
{ name: "zimbabwe", emoji: "🇿🇼" },
];

type AppProps = Omit<
SelectInitialState,
keyof (PopoverInitialState & CompositeInitialState)
>;

export const App: React.FC<AppProps> = props => {
export const App: React.FC<SelectInitialState> = props => {
const state = useSelectState(props);

return (
Expand Down
18 changes: 11 additions & 7 deletions src/select/stories/Select.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "./Select.css";
import React from "react";
import { Meta, Story } from "@storybook/react";
import { Meta } from "@storybook/react";
import { CompositeInitialState, PopoverInitialState } from "reakit";

import { App as Select } from "./Select.component";
import {
Expand All @@ -14,11 +15,17 @@ import {
SelectOption,
SelectTrigger,
useSelectState,
SelectInitialState,
Select as SelectComponent,
} from "..";

export const Default: React.FC<Omit<
SelectInitialState,
keyof (PopoverInitialState & CompositeInitialState)
>> = props => <Select {...props} />;

export default {
component: Select,
component: Default,
title: "Select/Basic",
parameters: {
preview: createPreviewTabs({
Expand Down Expand Up @@ -46,13 +53,10 @@ const countries = [
{ name: "zimbabwe", emoji: "🇿🇼" },
];

const Base: Story = args => <Select {...args} />;

export const Default = Base.bind({});
export const MultiSelect = Base.bind({});
export const MultiSelect = Default.bind({});
MultiSelect.args = { allowMultiselect: true };

export const DefaultSelected = Base.bind({});
export const DefaultSelected = Default.bind({});
DefaultSelected.args = { selected: "india" };

export const Scrolling: React.FC = () => {
Expand Down
Loading

0 comments on commit efbe598

Please sign in to comment.