-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat(component): added a Toast component that reads the label, the po… #157
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
There are no files selected for viewing
This file contains 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,47 @@ | ||
import { component$ } from '@builder.io/qwik'; | ||
import { Toast as HeadlessToast } from '@qwik-ui/headless'; | ||
|
||
interface ToastProps { | ||
class?: string; | ||
top?: boolean; | ||
center?: boolean; | ||
end?: boolean; | ||
middle?: boolean; | ||
bottom?: boolean; | ||
start?: boolean; | ||
label?: string; | ||
alert?: string; | ||
} | ||
|
||
export const Toast = component$((props: ToastProps) => { | ||
const { label, top, start, center, end, middle, bottom, alert, ...rest } = | ||
props; | ||
|
||
return ( | ||
<div class="form-control"> | ||
<label class="label cursor-pointer"> | ||
<div | ||
style={{ | ||
position: 'relative', | ||
border: 'solid', | ||
width: '480px', | ||
height: '240px', | ||
borderRadius: '12px', | ||
background: 'rgb(220,220,220)', | ||
gioboa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}} | ||
> | ||
<HeadlessToast | ||
alert={alert} | ||
label={label} | ||
class={`toast ${start && 'toast-start'} ${top && 'toast-top'} ${ | ||
center && 'toast-center' | ||
} ${end && 'toast-end'} ${middle && 'toast-middle'} ${ | ||
bottom && 'toast-bottom' | ||
}`} | ||
gioboa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{...rest} | ||
/> | ||
</div> | ||
</label> | ||
</div> | ||
); | ||
}); |
This file contains 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
This file contains 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,32 @@ | ||
import { component$ } from '@builder.io/qwik'; | ||
interface ToastProps { | ||
value?: string; | ||
/** | ||
* The controlled state of the toast. | ||
*/ | ||
|
||
label?: string; | ||
alert?: string; | ||
/** | ||
* The state of the toast when initially rendered. Use `defaultPressed` | ||
* if you do not need to control the state of the toast. | ||
* @defaultValue false | ||
*/ | ||
} | ||
|
||
export const Toast = component$((props: ToastProps) => { | ||
const { alert = 'info', label, ...toastProps } = props; | ||
gioboa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return ( | ||
<div class="toast" style={{ position: 'absolute' }} {...toastProps}> | ||
gioboa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<div | ||
class={`alert alert-${alert}`} | ||
gioboa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
style={{ background: alert === 'error' ? 'red' : 'auto' }} | ||
> | ||
<div> | ||
<span>{label}</span> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}); |
This file contains 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
This file contains 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
This file contains 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,25 @@ | ||
import { component$ } from '@builder.io/qwik'; | ||
import { Toast } from '@qwik-ui/theme-daisy'; | ||
|
||
export default component$(() => { | ||
return ( | ||
<> | ||
<h2>This is the documentation for the Toast</h2> | ||
<h1>toast with alert inside</h1> | ||
<Toast label="New Message" alert="success" /> | ||
<h1>toast with top & start attributes</h1> | ||
<Toast label="Errored" top start alert="error" /> | ||
<h1>toast with top & center attributes</h1> | ||
<Toast label="Information" top center alert="info" /> | ||
<h1>toast with top & end attributes</h1> | ||
<Toast | ||
label="You should probably think twice about it" | ||
top | ||
end | ||
alert="warning" | ||
/> | ||
<h1>toast with middle & start attributes</h1> | ||
<Toast label="New Message" start middle /> | ||
</> | ||
); | ||
}); |
This file contains 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,11 @@ | ||
import { component$ } from '@builder.io/qwik'; | ||
import { Toast } from '@qwik-ui/headless'; | ||
|
||
export default component$(() => { | ||
return ( | ||
<> | ||
<h2>This is the documentation for the Toast</h2> | ||
<Toast /> | ||
</> | ||
); | ||
}); |
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.
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.
On it