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

Replaces Flash with react-hot-toast #1856

Merged
merged 26 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
151304c
Add toast dependency
cannikin Feb 25, 2021
809adf1
Proxy Flash and addMessage to toast
cannikin Feb 25, 2021
1b42738
Back to console.warn()
cannikin Feb 25, 2021
07b3f4e
Remove unused code
cannikin Feb 25, 2021
5d187de
Update Flash README with deprecation notice
cannikin Feb 25, 2021
e2b3eb0
Removed flash tests
cannikin Feb 25, 2021
7f37c26
Updates templates to switch from Flash to react-hot-toast
cannikin Feb 25, 2021
c429c30
Export toast from @redwoodjs/web
cannikin Feb 25, 2021
eaa81f3
Style updates to scaffold to avoid overriding toast defaults
cannikin Feb 25, 2021
8b202ea
More efficient export
cannikin Feb 25, 2021
cf8eddb
Update tests
cannikin Feb 25, 2021
824eb4d
Merge branch 'main' into rc-react-hot-toast
Tobbe Feb 27, 2021
fcd1121
Add @deprecated comments
cannikin Mar 3, 2021
428e9a3
Merge remote-tracking branch 'origin/main' into rc-react-hot-toast
peterp Mar 7, 2021
b6c48f8
Put toast into @redwoodjs/web/toast.
peterp Mar 7, 2021
e8a3661
Fix typings reference.
peterp Mar 7, 2021
5578d5b
Move toast thing to src/toast instead of src/flash.
peterp Mar 7, 2021
c0d0c94
Add toast to package.json::files.
peterp Mar 7, 2021
6d1043d
Link to RHT in docs.
peterp Mar 7, 2021
46d9de3
Merge branch 'rc-react-hot-toast' of github.com:redwoodjs/redwood int…
peterp Mar 7, 2021
a616e7f
Merge branch 'main' into rc-react-hot-toast
dac09 Mar 7, 2021
cf85530
Update packages/web/toast/package.json
peterp Mar 8, 2021
2f0a01a
Fix spelling mistake.
peterp Mar 8, 2021
69688e8
Fix exec to cross-env.
peterp Mar 8, 2021
e95eb46
Merge branch 'main' into rc-react-hot-toast
peterp Mar 8, 2021
9247dff
Merge remote-tracking branch 'origin/main' into rc-react-hot-toast
peterp Mar 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
.rw-scaffold ::after,
.rw-scaffold ::before {
box-sizing: inherit;
border-width: 0;
border-style: solid;
border-color: #e2e8f0;
}
.rw-scaffold main {
color: #4a5568;
Expand Down Expand Up @@ -102,35 +99,6 @@
color: #1a202c;
text-decoration: underline;
}
.rw-flash-message {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin: 0 1rem;
padding: 1rem;
background: #e2e8f0;
border-radius: 0.25rem;
}
.rw-flash-message .rw-flash-message-dismiss {
font-size: 1.25rem;
font-weight: 600;
line-height: 1;
margin-right: 0.25rem;
transform-origin: center;
transform: rotate(45deg);
cursor: pointer;
}
.rw-flash-message .rw-flash-message-dismiss:hover {
opacity: 0.7;
}
.rw-flash-message.rw-flash-success {
background: #48bb78;
color: #fff;
}
.rw-flash-message.rw-flash-error {
background: #e53e3e;
color: #fff;
}
.rw-form-wrapper {
box-sizing: border-box;
font-size: 0.875rem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMutation, useFlash } from '@redwoodjs/web'
import { useMutation, toast } from '@redwoodjs/web'
import { navigate, routes } from '@redwoodjs/router'
import PostForm from 'src/components/PostForm'

Expand Down Expand Up @@ -40,11 +40,10 @@ const UPDATE_POST_MUTATION = gql`
export const Loading = () => <div>Loading...</div>

export const Success = ({ post }) => {
const { addMessage } = useFlash()
const [updatePost, { loading, error }] = useMutation(UPDATE_POST_MUTATION, {
onCompleted: () => {
toast.success('Post updated')
navigate(routes.posts())
addMessage('Post updated.', { classes: 'rw-flash-success' })
},
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMutation, useFlash } from '@redwoodjs/web'
import { useMutation, toast } from '@redwoodjs/web'
import { navigate, routes } from '@redwoodjs/router'
import UserProfileForm from 'src/components/UserProfileForm'

Expand Down Expand Up @@ -27,13 +27,12 @@ const UPDATE_USER_PROFILE_MUTATION = gql`
export const Loading = () => <div>Loading...</div>

export const Success = ({ userProfile }) => {
const { addMessage } = useFlash()
const [updateUserProfile, { loading, error }] = useMutation(
UPDATE_USER_PROFILE_MUTATION,
{
onCompleted: () => {
toast.success('UserProfile updated')
navigate(routes.userProfiles())
addMessage('UserProfile updated.', { classes: 'rw-flash-success' })
},
}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMutation, useFlash } from '@redwoodjs/web'
import { useMutation, toast } from '@redwoodjs/web'
import { navigate, routes } from '@redwoodjs/router'
import UserProfileForm from 'src/components/UserProfileForm'

Expand All @@ -13,13 +13,12 @@ const CREATE_USER_PROFILE_MUTATION = gql`
`

const NewUserProfile = () => {
const { addMessage } = useFlash()
const [createUserProfile, { loading, error }] = useMutation(
CREATE_USER_PROFILE_MUTATION,
{
onCompleted: () => {
toast.success('UserProfile created')
navigate(routes.userProfiles())
addMessage('UserProfile created.', { classes: 'rw-flash-success' })
},
}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMutation, useFlash } from '@redwoodjs/web'
import { useMutation, toast } from '@redwoodjs/web'
import { Link, routes } from '@redwoodjs/router'

import { QUERY } from 'src/components/PostsCell'
Expand Down Expand Up @@ -38,10 +38,9 @@ const checkboxInputTag = (checked) => {
}

const PostsList = ({ posts }) => {
const { addMessage } = useFlash()
const [deletePost] = useMutation(DELETE_POST_MUTATION, {
onCompleted: () => {
addMessage('Post deleted.', { classes: 'rw-flash-success' })
toast.success('Post deleted')
},
// This refetches the query on the list page. Read more about other ways to
// update the cache over here:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMutation, useFlash } from '@redwoodjs/web'
import { useMutation, toast } from '@redwoodjs/web'
import { navigate, routes } from '@redwoodjs/router'
import PostForm from 'src/components/PostForm'

Expand All @@ -13,11 +13,10 @@ const CREATE_POST_MUTATION = gql`
`

const NewPost = () => {
const { addMessage } = useFlash()
const [createPost, { loading, error }] = useMutation(CREATE_POST_MUTATION, {
onCompleted: () => {
toast.success('Post created')
navigate(routes.posts())
addMessage('Post created.', { classes: 'rw-flash-success' })
},
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMutation, useFlash } from '@redwoodjs/web'
import { useMutation, toast } from '@redwoodjs/web'
import { Link, routes, navigate } from '@redwoodjs/router'

import { QUERY } from 'src/components/PostsCell'
Expand Down Expand Up @@ -32,11 +32,10 @@ const checkboxInputTag = (checked) => {
}

const Post = ({ post }) => {
const { addMessage } = useFlash()
const [deletePost] = useMutation(DELETE_POST_MUTATION, {
onCompleted: () => {
toast.success('Post deleted')
navigate(routes.posts())
addMessage('Post deleted.', { classes: 'rw-flash-success' })
},
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Link, routes } from '@redwoodjs/router'
import { Flash } from '@redwoodjs/web'
import { Toaster } from '@redwoodjs/web'

const PostsLayout = (props) => {
return (
<div className="rw-scaffold">
<Flash timeout={1000} />
<Toaster />
<header className="rw-header">
<h1 className="rw-heading rw-heading-primary">
<Link to={routes.posts()} className="rw-link">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
.rw-scaffold ::after,
.rw-scaffold ::before {
box-sizing: inherit;
border-width: 0;
border-style: solid;
border-color: #e2e8f0;
}
.rw-scaffold main {
color: #4a5568;
Expand Down Expand Up @@ -102,35 +99,6 @@
color: #1a202c;
text-decoration: underline;
}
.rw-flash-message {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin: 0 1rem;
padding: 1rem;
background: #e2e8f0;
border-radius: 0.25rem;
}
.rw-flash-message .rw-flash-message-dismiss {
font-size: 1.25rem;
font-weight: 600;
line-height: 1;
margin-right: 0.25rem;
transform-origin: center;
transform: rotate(45deg);
cursor: pointer;
}
.rw-flash-message .rw-flash-message-dismiss:hover {
opacity: 0.7;
}
.rw-flash-message.rw-flash-success {
background: #48bb78;
color: #fff;
}
.rw-flash-message.rw-flash-error {
background: #e53e3e;
color: #fff;
}
.rw-form-wrapper {
box-sizing: border-box;
font-size: 0.875rem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMutation, useFlash } from '@redwoodjs/web'
import { useMutation, toast } from '@redwoodjs/web'
import { navigate, routes } from '@redwoodjs/router'
import ${singularPascalName}Form from 'src/components/${pascalScaffoldPath}${singularPascalName}Form'

Expand All @@ -20,11 +20,10 @@ const UPDATE_${singularConstantName}_MUTATION = gql`
export const Loading = () => <div>Loading...</div>

export const Success = ({ ${singularCamelName} }) => {
const { addMessage } = useFlash()
const [update${singularPascalName}, { loading, error }] = useMutation(UPDATE_${singularConstantName}_MUTATION, {
onCompleted: () => {
toast.success('${singularPascalName} updated')
navigate(routes.${pluralRouteName}())
addMessage('${singularPascalName} updated.', { classes: 'rw-flash-success' })
},
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMutation, useFlash } from '@redwoodjs/web'
import { useMutation, toast } from '@redwoodjs/web'
import { Link, routes, navigate } from '@redwoodjs/router'

import { QUERY } from 'src/components/${pascalScaffoldPath}${pluralPascalName}Cell'
Expand Down Expand Up @@ -32,11 +32,10 @@ const checkboxInputTag = (checked) => {
}

const ${singularPascalName} = ({ ${singularCamelName} }) => {
const { addMessage } = useFlash()
const [delete${singularPascalName}] = useMutation(DELETE_${singularConstantName}_MUTATION, {
onCompleted: () => {
toast.success('${singularPascalName} deleted')
navigate(routes.${pluralRouteName}())
addMessage('${singularPascalName} deleted.', { classes: 'rw-flash-success' })
},
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMutation, useFlash } from '@redwoodjs/web'
import { useMutation, toast } from '@redwoodjs/web'
import { Link, routes } from '@redwoodjs/router'

import { QUERY } from 'src/components/${pascalScaffoldPath}${pluralPascalName}Cell'
Expand Down Expand Up @@ -38,10 +38,9 @@ const checkboxInputTag = (checked) => {
}

const ${pluralPascalName}List = ({ ${pluralCamelName} }) => {
const { addMessage } = useFlash()
const [delete${singularPascalName}] = useMutation(DELETE_${singularConstantName}_MUTATION, {
onCompleted: () => {
addMessage('${singularPascalName} deleted.', { classes: 'rw-flash-success' })
toast.success('${singularPascalName} deleted')
},
// This refetches the query on the list page. Read more about other ways to
// update the cache over here:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMutation, useFlash } from '@redwoodjs/web'
import { useMutation, toast } from '@redwoodjs/web'
import { navigate, routes } from '@redwoodjs/router'
import ${singularPascalName}Form from 'src/components/${pascalScaffoldPath}${singularPascalName}Form'

Expand All @@ -13,11 +13,10 @@ const CREATE_${singularConstantName}_MUTATION = gql`
`

const New${singularPascalName} = () => {
const { addMessage } = useFlash()
const [create${singularPascalName}, { loading, error }] = useMutation(CREATE_${singularConstantName}_MUTATION, {
onCompleted: () => {
toast.success('${singularPascalName} created')
navigate(routes.${pluralRouteName}())
addMessage('${singularPascalName} created.', { classes: 'rw-flash-success' })
},
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Link, routes } from '@redwoodjs/router'
import { Flash } from '@redwoodjs/web'
import { Toaster } from '@redwoodjs/web'

const ${pluralPascalName}Layout = (props) => {
return (
<div className="rw-scaffold">
<Flash timeout={1000} />
<Toaster />
<header className="rw-header">
<h1 className="rw-heading rw-heading-primary">
<Link
Expand Down
3 changes: 2 additions & 1 deletion packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"@types/react": "16.9.53",
"core-js": "3.6.5",
"graphql": "^15.3.0",
"proptypes": "^1.1.0"
"proptypes": "^1.1.0",
"react-hot-toast": "^1.0.2"
},
"peerDependencies": {
"react": "*"
Expand Down
3 changes: 1 addition & 2 deletions packages/web/src/apollo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
useFetchConfig,
} from 'src/components/FetchConfigProvider'
import { GraphQLHooksProvider } from 'src/components/GraphQLHooksProvider'
import { FlashProvider } from 'src/flash'

const ApolloProviderWithFetchConfig: React.FunctionComponent<{
config?: Omit<ApolloClientOptions<InMemoryCache>, 'cache'>
Expand Down Expand Up @@ -76,7 +75,7 @@ export const RedwoodApolloProvider: React.FunctionComponent<{
<FetchConfigProvider useAuth={useAuth}>
<ApolloProviderWithFetchConfig config={graphQLClientConfig}>
<GraphQLHooksProvider useQuery={useQuery} useMutation={useMutation}>
<FlashProvider>{children}</FlashProvider>
{children}
</GraphQLHooksProvider>
</ApolloProviderWithFetchConfig>
</FetchConfigProvider>
Expand Down
Loading