Skip to content
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

Allow icons to be changed by the user #74

Merged
merged 15 commits into from
Oct 18, 2018
Merged

Conversation

tabby-or-not
Copy link
Contributor

@tabby-or-not tabby-or-not commented Oct 17, 2018

Remove dependency on font awesome 4 by allowing users to specify their own icons using the icons prop. This overrides only those specified.

i.e.

<ObjectList icons={{FavouritesIcon: <MyFavourites />}} />

Defaults added for FA4 FA5, use:

import {FontAwesome} from 'react-object-list/icons'
<ObjectList icons={FontAwesome(5)} />

This will check if the required version of font awesome is loaded in the DOM and warn if not.
Either way it'll apply the icons you picked (so as not to cause problems for false negatives)

@tabby-or-not tabby-or-not added the enhancement New feature or request label Oct 17, 2018
@codecov-io
Copy link

codecov-io commented Oct 17, 2018

Codecov Report

Merging #74 into master will decrease coverage by 0.37%.
The diff coverage is 90.24%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #74      +/-   ##
==========================================
- Coverage   95.54%   95.16%   -0.38%     
==========================================
  Files          60       60              
  Lines         718      745      +27     
  Branches      171      175       +4     
==========================================
+ Hits          686      709      +23     
- Misses         21       25       +4     
  Partials       11       11
Impacted Files Coverage Δ
src/pagination/Pagination.js 100% <ø> (ø) ⬆️
src/actions-filters/ActionsFiltersContainer.js 93.33% <ø> (ø) ⬆️
src/ObjectList.js 100% <ø> (ø) ⬆️
src/actions-filters/FiltersContainer.js 100% <100%> (ø) ⬆️
src/data-renderers/HeaderField.js 100% <100%> (ø) ⬆️
src/data-renderers/TableHeader.js 100% <100%> (ø) ⬆️
src/actions-filters/Favourites.js 100% <100%> (ø) ⬆️
src/filters/utils/makeFilter.js 100% <100%> (ø) ⬆️
src/actions-filters/OptionalFields.js 93.75% <100%> (+0.64%) ⬆️
src/filters/utils/RemoveFilter.js 100% <100%> (ø) ⬆️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e01426f...7fe53aa. Read the comment docs.

Copy link
Member

@jarekwg jarekwg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Awesome stuff!

.storybook/webpack.config.js Show resolved Hide resolved
demo-site/table-demo.jsx Show resolved Hide resolved
@@ -181,6 +182,7 @@ class InteractiveObjectList extends React.Component {
updateFilter={this.updateFilter}
searchKey="first_name"
itemOnClick={action('clicked on')}
icons={FontAwesomeIcons(5)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this supposed to be inconsistent with the other place? FontAwesome(4) vs FontAwesomeIcons(5)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, forgot to update this after adding the index file

@@ -93,6 +103,7 @@ class ObjectList extends Component {
Pagination: DefaultPagination,
ErrorMessage: DefaultErrorMessage,
data: [],
icons: {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the css file that we publish with the js already has FA included, I do think we should have some defaults set up to work out of the box.

Copy link
Contributor Author

@tabby-or-not tabby-or-not Oct 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not any more 😈
https://github.com/uptick/react-object-list/pull/74/files#diff-5fea21b08a353ec25a50a2178f880439L1

Default is currently no icons so that there is no dependency, but we could revert that, thoughts @scaredcat @jarekwg ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep I like it. As long as there are still icons in the demo, we're good.
Maybes also adjust the main README to explain how this package treats icons now (import your own, feed them into the props)

span.style.display = 'none'
document.body.insertBefore(span, document.body.firstChild)

const css = (element, property) => window.getComputedStyle(element, null).getPropertyValue(property)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🆒

@tabby-or-not tabby-or-not merged commit 7cb4f7b into master Oct 18, 2018
@tabby-or-not tabby-or-not deleted the feature/icons-override branch October 18, 2018 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants