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

alert toast component #248

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
94572f6
alert toast
iamgabrielsoft Jul 4, 2024
c6df9dd
remove alert position for now
iamgabrielsoft Jul 4, 2024
d439310
lint file working on useToast hook
iamgabrielsoft Jul 4, 2024
f73a83b
lint files
iamgabrielsoft Jul 4, 2024
62addcd
theme not added yet
iamgabrielsoft Jul 17, 2024
79117fa
fix build
iamgabrielsoft Jul 17, 2024
9f149c1
check build error
iamgabrielsoft Jul 17, 2024
b131ed2
alert review fix
iamgabrielsoft Jul 19, 2024
ce95381
alert toast
iamgabrielsoft Jul 4, 2024
e5440ea
remove alert position for now
iamgabrielsoft Jul 4, 2024
0f6eb6c
lint file working on useToast hook
iamgabrielsoft Jul 4, 2024
7e44b33
lint files
iamgabrielsoft Jul 4, 2024
3d68e60
theme not added yet
iamgabrielsoft Jul 17, 2024
64ce771
fix build
iamgabrielsoft Jul 17, 2024
0524edf
check build error
iamgabrielsoft Jul 17, 2024
7953e4c
review and resolved conflict
iamgabrielsoft Jul 19, 2024
3ec5221
merge
iamgabrielsoft Jul 19, 2024
2caef63
edited default alert
iamgabrielsoft Jul 19, 2024
374c80a
added more description to alert
iamgabrielsoft Jul 19, 2024
b28f407
added description
iamgabrielsoft Jul 25, 2024
14ec3d6
remove alert plugin type
iamgabrielsoft Jul 25, 2024
7799dc7
fix build error
iamgabrielsoft Jul 25, 2024
fbd7ca2
Merge remote-tracking branch 'origin' into feat/alert
iamgabrielsoft Aug 1, 2024
7b76630
resolving merge
iamgabrielsoft Aug 1, 2024
8ebbcd5
lint file
iamgabrielsoft Aug 1, 2024
8a9b369
lint files
iamgabrielsoft Jul 4, 2024
5a41e1c
theme not added yet
iamgabrielsoft Jul 17, 2024
43e9d83
check build error
iamgabrielsoft Jul 17, 2024
6ed401f
added theme attr to alert
iamgabrielsoft Aug 8, 2024
1e1d2f0
remove unecessary styles
iamgabrielsoft Aug 8, 2024
f724101
Update codex-ui/src/vue/components/alert/BaseAlert.vue
iamgabrielsoft Aug 14, 2024
8b26112
removed computed styles property
iamgabrielsoft Aug 15, 2024
468be67
added alert type methods
iamgabrielsoft Aug 15, 2024
18f3575
removed unecessaru styles
iamgabrielsoft Aug 15, 2024
b64c389
moved z-index to z-axis file
iamgabrielsoft Aug 18, 2024
de4a5e7
remove core folder
iamgabrielsoft Aug 22, 2024
e6a1d47
remove usestore from alert hook
iamgabrielsoft Sep 17, 2024
8859247
review fix
iamgabrielsoft Sep 24, 2024
4509f67
removed alert constant
iamgabrielsoft Sep 26, 2024
e200e7b
triggerAlert props are constant
iamgabrielsoft Sep 28, 2024
cbe1b01
fix transition
iamgabrielsoft Oct 11, 2024
6ad6208
rm reduntant props
iamgabrielsoft Oct 21, 2024
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
13 changes: 11 additions & 2 deletions codex-ui/dev/Playground.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
</div>
</div>
<Popover />
<AlertContainer />
</div>
</template>

Expand All @@ -38,8 +39,10 @@ import { computed } from 'vue';
import {
VerticalMenu,
Tabbar,
Popover
Popover,
AlertContainer
} from '../src/vue';

import { useTheme } from '../src/vue/composables/useTheme';

import { useRouter, useRoute } from 'vue-router';
Expand Down Expand Up @@ -197,6 +200,12 @@ const pages = computed(() => [
onActivate: () => router.push('/components/editor'),
isActive: route.path === '/components/editor',
},

{
title: 'Alert',
onActivate: () => router.push('/components/alert'),
isActive: route.path === '/components/alert',
},
],
},
]);
Expand All @@ -206,7 +215,7 @@ const pages = computed(() => [
.playground {
background-color: var(--base--bg-primary);
color: var(--base--text);
min-height: 100%;
min-height: 100vh;
Copy link
Member

Choose a reason for hiding this comment

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

min hight 100% worked fine

Copy link
Member

Choose a reason for hiding this comment

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

actual

Copy link
Member

Choose a reason for hiding this comment

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

still actual

}
.header {
display: grid;
Expand Down
150 changes: 150 additions & 0 deletions codex-ui/dev/pages/components/Alert.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<template>
<PageHeader>
Alert
<template #description>
Light and beautiful codex alert
<code>click the button to see for yourself </code>
</template>
</PageHeader>

<p>The following outlines options for alert to display </p>

<div class="flex-content">
<div>
Message - message of the alert to be displayed (string)
</div>

<div>
Position - position of alert (bottom-center)
</div>

<div>
Type - alert type (success, error, warning, info and default)
</div>

<div>
Timeout - visibility duration in milliseconds, set timeout to keep alert visible
</div>
</div>

<div class="flex-type">
<div class="flex">
neSpecc marked this conversation as resolved.
Show resolved Hide resolved
<span>Success</span>
<Button
@click="showSuccessAlert"
>
Show success alert
</Button>
</div>

<div class="flex">
<span>Error</span>
<Button
@click="showErrorAlert"
>
Show error alert
</Button>
</div>

<div class="flex">
<span>Warning</span>
<Button
@click="showWarningAlert"
>
Show warning alert
</Button>
</div>

<div class="flex">
<span>Info</span>
<Button
@click="showInfoAlert"
>
Show info alert
</Button>
</div>

<div class="flex">
<span>Default</span>
<Button
@click="showDefaultAlert"
>
Show default alert
</Button>
</div>
</div>

<AlertContainer />
Copy link
Member

Choose a reason for hiding this comment

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

lets move it to the root component (Playground.vue) to reuse the single container for the whole app

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved

Copy link
Member

Choose a reason for hiding this comment

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

not fixed

Copy link
Member

Choose a reason for hiding this comment

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

still actual

</template>

<script setup lang="ts">
import PageHeader from '../../components/PageHeader.vue';
import { Button, useAlert, AlertContainer } from '../../../src/vue';

const { success, error, warning, info, alert } = useAlert();

const showSuccessAlert = () => {
success({
message: 'codex',
timeout: 5000,
});
};

const showErrorAlert = () => {
error({
message: 'codex',
timeout: 5000,
});
};

const showWarningAlert = () => {
warning({
message: 'codex',
timeout: 5000,
});
};

const showInfoAlert = () => {
info({
message: 'codex',
timeout: 5000,
});
};

const showDefaultAlert = () => {
alert({
message: 'codex',
timeout: 5000,
});
};

</script>

<style lang="postcss">
.flex-content {
display: grid;
grid-template-columns: 1fr;
gap: var(--spacing-l);
align-items: center;
}

.flex-type {
display: grid;
grid-template-columns: repeat(1, 2fr);
gap: var(--spacing-l);
align-items: center;
margin-top: 2rem;

.flex {
display: grid;
grid-template-columns: repeat(5, 1fr);
align-items: center;
gap: var(--spacing-l);

button {
display: grid;
grid-column: span 1;
}
}
}
</style>
6 changes: 6 additions & 0 deletions codex-ui/dev/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import VerticalMenu from './pages/components/VerticalMenu.vue';
import ContextMenu from './pages/components/ContextMenu.vue';
import Editor from './pages/components/Editor.vue';
import ThemePreview from './pages/components/ThemePreview.vue';
import Alert from './pages/components/Alert.vue';

/**
* Vue router routes list
Expand Down Expand Up @@ -145,6 +146,11 @@ const routes: RouteRecordRaw[] = [
path: '/components/theme-preview',
component: ThemePreview as Component,
},

{
path: '/components/alert',
component: Alert as Component,
},
];

export default routes;
1 change: 1 addition & 0 deletions codex-ui/src/styles/z-axis.pcss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
:root {
--z-popover: 3;
--z-alert: calc(var(--z-popover) + 1)
}
35 changes: 35 additions & 0 deletions codex-ui/src/vue/components/alert/Alert.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Various alert type
*/
export type AlerType = 'success' | 'error' | 'warning' | 'info' | 'default';

/**
* alert configuration
*/
export interface AlertOptions {
/** unique alert id */
id?: string;

/**
* Custom icon class to be used.
*
*/
icon?: string;

/**
* content to be rendered
*/
message: string;

/**
* Type of the alert.
*
* Can be any of `(success, error, default, info, warning)`
*/
type?: AlerType;

/**
* How many milliseconds for the alert to be auto dismissed
*/
timeout?: number;
}
107 changes: 107 additions & 0 deletions codex-ui/src/vue/components/alert/Alert.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<template>
<div
ref="el"
:class="[
$style.alert,
$style['alert--' + props.type]
]"
:theme-base="computedTheme"
>
<Icon
v-show="icon"
:name="icon"
/>
<div>{{ props.message }}</div>
</div>
</template>

<script setup lang="ts">
import { defineProps, computed, ref } from 'vue';
import Icon from '../icon/Icon.vue';
import type { AlertOptions } from './Alert.types';

const el = ref<HTMLElement>();

const props = withDefaults(defineProps<AlertOptions>(), {
id: `alert-'${Math.random()}`,
position: 'bottom-center',
message: '',
icon: '',
type: 'default',
timeout: 5000,
});

/**
* Various alert theme type
*/
export type AlertTheme = 'grass' | 'red' | 'amber' | 'graphite' | undefined;

/**
*
* computed theme
*/
const computedTheme = computed((): AlertTheme => {
switch (props.type) {
case 'success':
return 'grass';

case 'error':
return 'red';

case 'warning':
return 'amber';

case 'info':
return 'graphite';

default:
return undefined;
}
});
</script>

<style module lang="postcss">
.alert {
position: relative;
box-sizing: border-box;
display: flex;
align-items: center;
gap: var(--v-padding);
border: 0;
margin-block-start: 0.4rem;
outline: 0;
font-family: inherit;
pointer-events: auto;
background-color: var(--base-text);
overflow: hidden;
word-break: keep-all;
direction: ltr;
padding: var(--v-padding) var(--h-padding) var(--v-padding) var(--h-padding);
border-radius: var(--radius-field);
color: var(--base--text-solid-foreground);
overflow-wrap: anywhere;
transform: translateY(10%);

&--success {
background-color: var(--base--solid);
}

&--error {
background-color: var(--base--solid);
}

&--warning {
background-color: var(--base--solid);
}

&--info {
background-color: var(--base--solid);
}

&--default {
color: var(--base--text);
background-color: var(--base--bg-secondary);
}
}

</style>
Loading
Loading