- Notifications
You must be signed in to change notification settings - Fork 431
Stories for Bootstrap 4 #496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Import bootstrap style by given version
- Loading branch information
commit a0f32bd6e300747d44820bd496f2c5221e7ef765
There are no files selected for viewing
This file contains hidden or 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 +19.7 KB packages/react-bootstrap-table2-example/public/fonts/glyphicons-halflings-regular.eot
Binary file not shown.
288 changes: 288 additions & 0 deletions 288 ...es/react-bootstrap-table2-example/public/fonts/glyphicons-halflings-regular.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BIN +44.3 KB packages/react-bootstrap-table2-example/public/fonts/glyphicons-halflings-regular.ttf
Binary file not shown.
Binary file added BIN +22.9 KB packages/react-bootstrap-table2-example/public/fonts/glyphicons-halflings-regular.woff
Binary file not shown.
Binary file added BIN +17.6 KB packages/react-bootstrap-table2-example/public/fonts/glyphicons-halflings-regular.woff2
Binary file not shown.
6 changes: 6 additions & 0 deletions 6 packages/react-bootstrap-table2-example/public/style/bootstrap.3.3.7.min.css
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions 7 packages/react-bootstrap-table2-example/public/style/bootstrap.4.1.3.min.css
Large diffs are not rendered by default.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions 56 packages/react-bootstrap-table2-example/stories/bootstrap-style.js
This file contains hidden or 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,56 @@ | ||
| /* eslint no-return-assign: 0 */ | ||
| import React, { Fragment, PureComponent } from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| | ||
| export const BOOTSTRAP_VERSION = { | ||
| FOUR: '4.1.3', | ||
| THREE: '3.3.7' | ||
| }; | ||
| | ||
| class WithBootstrapStyle extends PureComponent { | ||
| static propTypes = { | ||
| version: PropTypes.string.isRequired, | ||
| render: PropTypes.func.isRequired | ||
| } | ||
| | ||
| constructor() { | ||
| super(); | ||
| | ||
| this.state = { loading: true }; | ||
| } | ||
| | ||
| componentDidMount() { | ||
| this.style.addEventListener('load', this.handleLoadEvent); | ||
| } | ||
| | ||
| componentWillUnmount() { | ||
| this.style.removeEventListener('load', this.handleLoadEvent); | ||
| } | ||
| | ||
| handleLoadEvent = () => { | ||
| this.setState({ loading: false }); | ||
| } | ||
| | ||
| render() { | ||
| const { version, render } = this.props; | ||
| | ||
| const href = `style/bootstrap.${version}.min.css`; | ||
| | ||
| return ( | ||
| <Fragment> | ||
| <link href={ href } rel="stylesheet" ref={ element => this.style = element } /> | ||
| { render(this.state.loading) } | ||
| </Fragment> | ||
| ); | ||
| } | ||
| } | ||
| | ||
| /** | ||
| * Currently we adopt version 3 as default. | ||
| */ | ||
| export default (version = BOOTSTRAP_VERSION.THREE) => story => ( | ||
| <WithBootstrapStyle | ||
| version={ version } | ||
| render={ loading => !loading && story() } | ||
| /> | ||
| ); |
This file contains hidden or 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 |
|---|---|---|
| | @@ -156,20 +156,20 @@ import RemoteCellEdit from 'examples/remote/remote-celledit'; | |
| import RemoteAll from 'examples/remote/remote-all'; | ||
| | ||
| // css style | ||
| import 'bootstrap/dist/css/bootstrap.min.css'; | ||
| import 'stories/stylesheet/tomorrow.min.css'; | ||
| import 'stories/stylesheet/storybook.scss'; | ||
| import '../../react-bootstrap-table2/style/react-bootstrap-table2.scss'; | ||
| import '../../react-bootstrap-table2-paginator/style/react-bootstrap-table2-paginator.scss'; | ||
| import '../../react-bootstrap-table2-filter/style/react-bootstrap-table2-filter.scss'; | ||
| | ||
| // import { action } from '@storybook/addon-actions'; | ||
| // import bootstrap style by given version | ||
| import bootstrapStyle, { BOOTSTRAP_VERSION } from './bootstrap-style'; | ||
| Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good patch | ||
| | ||
| // action('hello'); | ||
| storiesOf('Welcome', module) | ||
| .add('react bootstrap table 2 ', () => <Welcome />); | ||
| | ||
| storiesOf('Basic Table', module) | ||
| .addDecorator(bootstrapStyle()) | ||
| .add('basic table', () => <BasicTable />) | ||
| .add('striped, hover, condensed table', () => <StripHoverCondensedTable />) | ||
| .add('borderless table', () => <BorderlessTable />) | ||
| | @@ -178,7 +178,13 @@ storiesOf('Basic Table', module) | |
| .add('Table with caption', () => <CaptionTable />) | ||
| .add('Large Table', () => <LargeTable />); | ||
| | ||
| storiesOf('Bootstrap 4', module) | ||
| .addDecorator(bootstrapStyle(BOOTSTRAP_VERSION.FOUR)) | ||
| .add('Basic Table', () => <BasicTable />) | ||
| .add('Basic Pagination Table', () => <PaginationTable />); | ||
| | ||
| storiesOf('Work on Columns', module) | ||
| .addDecorator(bootstrapStyle()) | ||
| .add('Display Nested Data', () => <NestedDataTable />) | ||
| .add('Column Formatter', () => <ColumnFormatTable />) | ||
| .add('Column Formatter with Custom Data', () => <ColumnFormatExtraDataTable />) | ||
| | @@ -191,6 +197,7 @@ storiesOf('Work on Columns', module) | |
| .add('Customize Column HTML attribute', () => <ColumnAttrsTable />); | ||
| | ||
| storiesOf('Work on Header Columns', module) | ||
| .addDecorator(bootstrapStyle()) | ||
| .add('Column Formatter', () => <HeaderColumnFormatTable />) | ||
| .add('Column Format with Filter and Sort', () => <HeaderColumnFormatWithSortFilterTable />) | ||
| .add('Column Align', () => <HeaderColumnAlignTable />) | ||
| | @@ -202,6 +209,7 @@ storiesOf('Work on Header Columns', module) | |
| .add('Header Class', () => <HeaderClassTable />); | ||
| | ||
| storiesOf('Column Filter', module) | ||
| .addDecorator(bootstrapStyle()) | ||
| .add('Text Filter', () => <TextFilter />) | ||
| .add('Text Filter with Default Value', () => <TextFilterWithDefaultValue />) | ||
| .add('Text Filter with Comparator', () => <TextFilterComparator />) | ||
| | @@ -232,11 +240,13 @@ storiesOf('Column Filter', module) | |
| .add('Clear All Filters', () => <ClearAllFilters />); | ||
| | ||
| storiesOf('Work on Rows', module) | ||
| .addDecorator(bootstrapStyle()) | ||
| .add('Customize Row Style', () => <RowStyleTable />) | ||
| .add('Customize Row Class', () => <RowClassTable />) | ||
| .add('Row Event', () => <RowEventTable />); | ||
| | ||
| storiesOf('Sort Table', module) | ||
| .addDecorator(bootstrapStyle()) | ||
| .add('Enable Sort', () => <EnableSortTable />) | ||
| .add('Default Sort Table', () => <DefaultSortTable />) | ||
| .add('Default Sort Direction Table', () => <DefaultSortDirectionTable />) | ||
| | @@ -246,6 +256,7 @@ storiesOf('Sort Table', module) | |
| .add('Custom Style on Sorting Header Column', () => <HeaderSortingStyleTable />); | ||
| | ||
| storiesOf('Cell Editing', module) | ||
| .addDecorator(bootstrapStyle()) | ||
| .add('Click to Edit', () => <ClickToEditTable />) | ||
| .add('DoubleClick to Edit', () => <DoubleClickToEditTable />) | ||
| .add('Blur to Save Cell', () => <BlurToSaveTable />) | ||
| | @@ -265,6 +276,7 @@ storiesOf('Cell Editing', module) | |
| .add('Custom Editor', () => <CustomEditorTable />); | ||
| | ||
| storiesOf('Row Selection', module) | ||
| .addDecorator(bootstrapStyle()) | ||
| .add('Single Selection', () => <SingleSelectionTable />) | ||
| .add('Multiple Selection', () => <MultipleSelectionTable />) | ||
| .add('Click to Select', () => <ClickToSelectTable />) | ||
| | @@ -281,6 +293,7 @@ storiesOf('Row Selection', module) | |
| .add('Hide Selection Column', () => <HideSelectionColumnTable />); | ||
| | ||
| storiesOf('Row Expand', module) | ||
| .addDecorator(bootstrapStyle()) | ||
| .add('Basic Row Expand', () => <BasicRowExpand />) | ||
| .add('Expand Management', () => <RowExpandManagement />) | ||
| .add('Non Expandabled Rows', () => <NonExpandableRows />) | ||
| | @@ -289,18 +302,21 @@ storiesOf('Row Expand', module) | |
| .add('Expand Hooks', () => <ExpandHooks />); | ||
| | ||
| storiesOf('Pagination', module) | ||
| .addDecorator(bootstrapStyle()) | ||
| .add('Basic Pagination Table', () => <PaginationTable />) | ||
| .add('Pagination Hooks', () => <PaginationHooksTable />) | ||
| .add('Custom Pagination', () => <CustomPaginationTable />); | ||
| | ||
| storiesOf('Table Search', module) | ||
| .addDecorator(bootstrapStyle()) | ||
| .add('Basic Search Table', () => <SearchTable />) | ||
| .add('Default Custom Search', () => <DefaultCustomSearch />) | ||
| .add('Fully Custom Search', () => <FullyCustomSearch />) | ||
| .add('Search Fromatted Value', () => <SearchFormattedData />) | ||
| .add('Custom Search Value', () => <CustomSearchValue />); | ||
| | ||
| storiesOf('Export CSV', module) | ||
| .addDecorator(bootstrapStyle()) | ||
| .add('Basic Export CSV', () => <ExportCSV />) | ||
| .add('Format CSV Column', () => <CSVFormatter />) | ||
| .add('Custom CSV Header', () => <CustomCSVHeader />) | ||
| | @@ -310,10 +326,12 @@ storiesOf('Export CSV', module) | |
| .add('Custom CSV', () => <CustomCSV />); | ||
| | ||
| storiesOf('EmptyTableOverlay', module) | ||
| .addDecorator(bootstrapStyle()) | ||
| .add('Empty Table Overlay', () => <EmptyTableOverlay />) | ||
| .add('Table Overlay', () => <TableOverlay />); | ||
| | ||
| storiesOf('Remote', module) | ||
| .addDecorator(bootstrapStyle()) | ||
| .add('Remote Sort', () => <RemoteSort />) | ||
| .add('Remote Filter', () => <RemoteFilter />) | ||
| .add('Remote Pagination', () => <RemotePaginationTable />) | ||
| | ||
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @AllenFang,
Instead of importing
stylefromnode_module, I decided to serve the style as static files alternatively. Theprosis that we could dynamically import style in our stories; theconsis that we have to store the files in the code base and ask for the style every time as long as we switch to another story. I'm not sure it's good or not. Please let me know if you have any concern, thanks :)