Skip to content

Commit

Permalink
DOCS (updates): add anchors to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
sanusart committed Sep 19, 2019
1 parent eb322a6 commit 8a50e14
Show file tree
Hide file tree
Showing 17 changed files with 138 additions and 146 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ and use as:
| create | bool | false | If true, select will create value from search string and fire `onCreateNew` callback prop |
| createNewLabel | string | "add {search}" | If create set to true, this will be the label of the "add new" component. `{search}` will be replaced by search value |
| disabledLabel | string | "disabled" | Label shown on disabled field (after) the text |
| additionalProps | object | null | Additional props to pass to Select |

### Callback props

Expand Down
27 changes: 12 additions & 15 deletions docs/src/examples/AccessDataByPath.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import React from 'react';
import styled from '@emotion/styled';

import Select from '../../../src';
import { options } from '../options';
import { Heading } from './components/Heading';

const AccessDataByPath = ({ title }) => (
<React.Fragment>
<Title>
<h2>{title}</h2>
<a href="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/AccessDataByPath.js">
Source
</a>
</Title>
<p>"Label" is accessed via <code>company.catchPhrase</code> nested property of the <a href="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/options.js#L21">options</a> object</p>
<Heading
title={title}
source="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/AccessDataByPath.js"
/>
<p>
"Label" is accessed via <code>company.catchPhrase</code> nested property of the{' '}
<a href="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/options.js#L21">
options
</a>{' '}
object
</p>
<Select
multi
options={options}
Expand All @@ -30,10 +33,4 @@ const AccessDataByPath = ({ title }) => (

AccessDataByPath.propTypes = {};

const Title = styled.div`
display: flex;
justify-content: space-between;
align-items: baseline;
`;

export default AccessDataByPath;
13 changes: 6 additions & 7 deletions docs/src/examples/Basic.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import React from 'react';
import styled from '@emotion/styled';

import { Heading } from './components/Heading';
import Select from '../../../src';

const Basic = ({ options, title }) => (
<React.Fragment>
<Title>
<h2>{title}</h2>
<a href="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/Basic.js">
Source
</a>
</Title>
<Heading
title={title}
source="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/Basic.js"
/>

<Select
options={options}
values={[]}
Expand Down
11 changes: 5 additions & 6 deletions docs/src/examples/CreateEntries.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import React from 'react';
import styled from '@emotion/styled';
import Select from '../../../src';
import { Heading } from './components/Heading';

const CreateEntries = ({ options, title }) => (
<React.Fragment>
<Title>
<h2>{title}</h2>
<a href="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/CreateEntries.js">
Source
</a>
</Title>
<Heading
title={title}
source="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/CreateEntries.js"
/>

<p>Type search and hit `Return` key</p>
<Select
Expand Down
13 changes: 6 additions & 7 deletions docs/src/examples/CustomContentAndDropdown.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import Select from '../../../src';

import styled from '@emotion/styled';
import { Heading } from './components/Heading';

export class CustomContentAndDropdown extends React.Component {
options = () =>
Expand Down Expand Up @@ -69,12 +69,11 @@ export class CustomContentAndDropdown extends React.Component {
render() {
return (
<div>
<Title>
<h2>{this.props.title}</h2>
<a href="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/CustomContentAndDropdown.js">
Source
</a>
</Title>
<Heading
title={this.props.title}
source="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/CustomContentAndDropdown.js"
/>

<StyledSelect
placeholder="Select"
multi
Expand Down
18 changes: 10 additions & 8 deletions docs/src/examples/DropdownAutoPosition.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import React from 'react';
import styled from '@emotion/styled';

import { Heading } from './components/Heading';
import Select from '../../../src';

const DropdownAutoPosition = ({ options, title }) => (
<React.Fragment>
<Title>
<h2>{title}</h2>
<a href="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/DropdownAutoPosition.js">
Source
</a>
</Title>
<p>Scroll the page so the dropdown will have no space to open on the bottom, also changes position when dropdown is open (and <code>closeOnScroll</code> prop is not set or false)</p>
<Heading
title={title}
source="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/DropdownAutoPosition.js"
/>

<p>
Scroll the page so the dropdown will have no space to open on the bottom, also changes
position when dropdown is open (and <code>closeOnScroll</code> prop is not set or false)
</p>
<Select
options={options}
values={[]}
Expand Down
13 changes: 6 additions & 7 deletions docs/src/examples/ExternalClear.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import styled from '@emotion/styled';

import { Heading } from './components/Heading';
import Select from '../../../src';

class ExternalClear extends Component {
Expand All @@ -23,12 +23,11 @@ class ExternalClear extends Component {
const { options, title } = this.props;
return (
<React.Fragment>
<Title>
<h2>{title}</h2>
<a href="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/ExternalClear.js">
Source
</a>
</Title>
<Heading
title={title}
source="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/ExternalClear.js"
/>

<p>I can be cleared from outside by setting values to <code>[]</code> <button href={() => null} onClick={() => this.onChange([])}>&times; clear</button></p>
<p>Values can be added from outside <button href={() => null} onClick={() => this.onSet([options[Math.floor(Math.random() * (10 - 1) + 1)]])}>&raquo; set</button></p>
<Select
Expand Down
12 changes: 6 additions & 6 deletions docs/src/examples/ItemRenderer.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from 'react';
import styled from '@emotion/styled';
import Select from '../../../src';
import { Heading } from './components/Heading';

const ItemRenderer = ({ options, title }) => (
<React.Fragment>
<Title>
<h2>{title}</h2>
<a href="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/ItemRenderer.js">
Source
</a>
</Title>
<Heading
title={title}
source="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/ItemRenderer.js"
/>

<Select
multi
options={options}
Expand Down
13 changes: 6 additions & 7 deletions docs/src/examples/Multi.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import React from 'react';
import styled from '@emotion/styled';

import { Heading } from './components/Heading';
import Select from '../../../src';

const Multi = ({ options, title }) => (
<React.Fragment>
<Title>
<h2>{title}</h2>
<a href="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/Multi.js">
Source
</a>
</Title>
<Heading
title={title}
source="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/Multi.js"
/>

<Select
multi
options={options}
Expand Down
20 changes: 5 additions & 15 deletions docs/src/examples/NoData.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import styled from '@emotion/styled';

import { Heading } from './components/Heading';
import Select from '../../../src';

export class NoData extends React.Component {
Expand Down Expand Up @@ -40,12 +40,10 @@ export class NoData extends React.Component {
render() {
return (
<div>
<Title>
<h2>{this.props.title}</h2>
<a href="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/NoData.js">
Source
</a>
</Title>
<Heading
title={this.props.title}
source="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/NoData.js"
/>

<Select
placeholder="Type to match nothing 😱"
Expand All @@ -61,16 +59,8 @@ export class NoData extends React.Component {
}
}

NoData.propTypes = {};

export default NoData;

const Title = styled.div`
display: flex;
justify-content: space-between;
align-items: baseline;
`;

const StyledNoData = styled.div`
padding: 10px;
color: #555;
Expand Down
21 changes: 6 additions & 15 deletions docs/src/examples/OpenOnTop.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import React from 'react';
import styled from '@emotion/styled';

import { Heading } from './components/Heading';
import Select from '../../../src';

const OpenOnTop = ({ options, title }) => (
<React.Fragment>
<Title>
<h2>{title}</h2>
<a href="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/OpenOnTop.js">
Source
</a>
</Title>
<Heading
title={title}
source="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/OpenOnTop.js"
/>

<Select
multi
dropdownPosition="top"
Expand All @@ -23,12 +22,4 @@ const OpenOnTop = ({ options, title }) => (
</React.Fragment>
);

OpenOnTop.propTypes = {};

const Title = styled.div`
display: flex;
justify-content: space-between;
align-items: baseline;
`;

export default OpenOnTop;
21 changes: 6 additions & 15 deletions docs/src/examples/RenderInBody.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import React from 'react';
import styled from '@emotion/styled';

import { Heading } from './components/Heading';
import Select from '../../../src';

const RenderInBody = ({ options, title }) => (
<React.Fragment>
<Title>
<h2>{title}</h2>
<a href="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/RenderInBody.js">
Source
</a>
</Title>
<Heading
title={title}
source="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/RenderInBody.js"
/>

<div style={{ overflow: 'auto', height: '100px' }}>
<p>
I am wrapped in: <code>&lt;div style="overflow: auto; height: 100px;"&gt;</code>
Expand All @@ -28,12 +27,4 @@ const RenderInBody = ({ options, title }) => (
</React.Fragment>
);

RenderInBody.propTypes = {};

const Title = styled.div`
display: flex;
justify-content: space-between;
align-items: baseline;
`;

export default RenderInBody;
21 changes: 6 additions & 15 deletions docs/src/examples/Rtl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import styled from '@emotion/styled';

import { Heading } from './components/Heading';
import Select from '../../../src';

const options = [
Expand Down Expand Up @@ -264,12 +264,11 @@ const options = [

const Rtl = ({ title }) => (
<React.Fragment>
<Title id="Right-to-left">
<h2>{title}</h2>
<a href="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/Rtl.js">
Source
</a>
</Title>
<Heading
title={title}
source="https://github.com/sanusart/react-dropdown-select/tree/master/docs/src/examples/Rtl.js"
/>

<Select
multi
options={options}
Expand All @@ -284,14 +283,6 @@ const Rtl = ({ title }) => (
</React.Fragment>
);

Rtl.propTypes = {};

const Title = styled.div`
display: flex;
justify-content: space-between;
align-items: baseline;
`;

const StyledNoData = styled.div`
padding: 10px;
color: #555;
Expand Down
Loading

0 comments on commit 8a50e14

Please sign in to comment.