Skip to content
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 3 commits into from
Feb 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
47 changes: 47 additions & 0 deletions packages/daisy/src/components/toast/toast.tsx
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;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export const Toast = component$((props: ToastProps) => {
const { label, top, start, center, end, middle, bottom, alert, ...rest } =
props;
export const Toast = component$(({ label, top, start, center, end, middle, bottom, alert, ...rest }: ToastProps) => {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On it


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>
);
});
1 change: 1 addition & 0 deletions packages/daisy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ export * from './components/drawer/drawer';
export * from './components/popover/popover';
export * from './components/rating/rating';
export * from './components/tabs';
export * from './components/toast/toast';
export * from './components/toggle/toggle';
export * from './components/tooltip/tooltip';
32 changes: 32 additions & 0 deletions packages/headless/src/components/toast/toast.tsx
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>
);
});
1 change: 1 addition & 0 deletions packages/headless/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './components/drawer';
export * from './components/popover';
export * from './components/rating/rating';
export * from './components/tabs/tabs';
export * from './components/toast/toast';
export * from './components/toggle/toggle';
export * from './components/tooltip/tooltip';
export * as Select from './components/select/select';
1 change: 1 addition & 0 deletions packages/website/src/components/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const Menu = component$<Props>(({ onClose$ }) => {
{ label: 'Popover', path: `/docs/${appState.theme.toLowerCase()}/popover` },
{ label: 'Select', path: `/docs/${appState.theme.toLowerCase()}/select` },
{ label: 'Tabs', path: `/docs/${appState.theme.toLowerCase()}/tabs` },
{ label: 'Toast', path: `/docs/${appState.theme.toLowerCase()}/toast` },
{ label: 'Toggle', path: `/docs/${appState.theme.toLowerCase()}/toggle` },
{ label: 'Tooltip', path: `/docs/${appState.theme.toLowerCase()}/tooltip` },
];
Expand Down
25 changes: 25 additions & 0 deletions packages/website/src/routes/docs/daisy/toast/index.tsx
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 />
</>
);
});
11 changes: 11 additions & 0 deletions packages/website/src/routes/docs/headless/toast/index.tsx
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 />
</>
);
});