diff --git a/.travis.yml b/.travis.yml index ad4d6e410..c19d800e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,6 @@ node_js: - lts/* script: - npm run extractor -- npm run builder after_success: - chmod +x .travis/push.sh -- .travis/push.sh \ No newline at end of file +- .travis/push.sh diff --git a/.travis/push.sh b/.travis/push.sh index f60647fd8..b3546d61f 100644 --- a/.travis/push.sh +++ b/.travis/push.sh @@ -25,7 +25,7 @@ upload_files() { if [ $TRAVIS_EVENT_TYPE != "pull_request" ]; then if [ $TRAVIS_BRANCH == "master" ]; then echo "Pushing to master branch..." - git push --force --quiet "https://${GH_TOKEN}@github.com/30-seconds/30-seconds-of-react.git" master > /dev/null 2>&1 + git push --quiet "https://${GH_TOKEN}@github.com/30-seconds/30-seconds-of-react.git" master > /dev/null 2>&1 fi fi } diff --git a/README.md b/README.md index 674d9e04f..369616e24 100644 --- a/README.md +++ b/README.md @@ -1,2506 +1,26 @@ -![Logo](/logo.png) +[![Logo](/logo.png)](https://30secondsofcode.org/react/p/1) # 30 seconds of React -> Curated collection of useful React snippets that you can understand in 30 seconds or less. +> Short React code snippets for all your development needs -- Use Ctrl + F or command + F to search for a snippet. -- Contributions welcome, please read the [contribution guide](CONTRIBUTING.md). -- Snippets are written in React 16.8+, using hooks. +* Visit [our website](https://30secondsofcode.org) to view our snippet collection. +* Use the [Search page](https://30secondsofcode.org/search) to find snippets that suit your needs. You can search by name, tag, language or using a snippet's description. Just start typing a term and see what comes up. +* Browse the [React Snippet List](https://30secondsofcode.org/react/p/1) to see all the snippets in this project or click individual tags at the top of the same page to narrow down your search to a specific tag. +* Click on each snippet card to view the whole snippet, including code, explanation and examples. +* You can use the button on the right side of a snippet card to copy the code to clipboard. +* If you like the project, give it a star. It means a lot to the people maintaining it. -### Prerequisites +## Want to contribute? -To import a snippet into your project, you must import `React` and copy-paste the component's JavaScript code like this: +* If you want to help us improve, take a minute to read the [Contribution Guidelines](/CONTRIBUTING.md) first. +* Use the [Snippet Template](/snippet-template.md) to add new snippets to the collection. +* If you find a problem with a specific snippet, please [open an issue](https://github.com/30-seconds/30-seconds-of-react/issues/new). +* If you find a problem with the website, please [report it in the web repository](https://github.com/30-seconds/30-seconds-web/issues/new). -```js -import React from 'react'; - -function MyComponent(props) { - /* ... */ -} -``` - -If there is any CSS related to your component, copy-paste it to a new file with the same name and the appropriate extension, then import it like this: - -```js -import './MyComponent.css'; -``` - -To render your component, make sure there is a node with and id of `"root"` present in your element (preferrably a `
`) and that you have imported `ReactDOM`, like this: - -```js -import ReactDOM from 'react-dom'; -``` - -#### Related projects - -- [30 Seconds of Code](https://30secondsofcode.org) -- [30 Seconds of CSS](https://30-seconds.github.io/30-seconds-of-css/) -- [30 Seconds of Interviews](https://30secondsofinterviews.org/) - -## Table of Contents - -### Array - -
-View contents - -* [`DataList`](#datalist) -* [`DataTable`](#datatable) -* [`MappedTable`](#mappedtable) - -
- -### Hooks - -
-View contents - -* [`useClickInside`](#useclickinside) -* [`useClickOutside`](#useclickoutside) -* [`useFetch`](#usefetch) -* [`useInterval`](#useinterval) -* [`useNavigatorOnLine`](#usenavigatoronline) -* [`useSSR`](#usessr) -* [`useTimeout`](#usetimeout) - -
- -### Input - -
-View contents - -* [`ControlledInput`](#controlledinput) -* [`LimitedTextarea`](#limitedtextarea) -* [`LimitedWordTextarea`](#limitedwordtextarea) -* [`MultiselectCheckbox`](#multiselectcheckbox) -* [`PasswordRevealer`](#passwordrevealer) -* [`Select`](#select) -* [`Slider`](#slider) -* [`TagInput`](#taginput) -* [`TextArea`](#textarea) -* [`UncontrolledInput`](#uncontrolledinput) - -
- -### Visual - -
-View contents - -* [`Accordion`](#accordion-) -* [`Alert`](#alert) -* [`AutoLink`](#autolink-) -* [`Carousel`](#carousel) -* [`Collapse`](#collapse) -* [`CountDown`](#countdown-) -* [`FileDrop`](#filedrop) -* [`Loader`](#loader) -* [`Mailto`](#mailto) -* [`Modal`](#modal) -* [`RippleButton`](#ripplebutton) -* [`StarRating`](#starrating) -* [`Tabs`](#tabs) -* [`Ticker`](#ticker) -* [`Toggle`](#toggle) -* [`Tooltip`](#tooltip) -* [`TreeView`](#treeview-) - -
- - ---- - -## Array - - -### DataList - -Renders a list of elements from an array of primitives. - -- Use the value of the `isOrdered` prop to conditionally render a `
    ` or `