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

UI-291: Popover > Improvement #306

Merged
merged 5 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
115 changes: 41 additions & 74 deletions packages/vue3/src/_dev/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,59 @@
import 'uno.css';
import '../assets/main.css';
import { ref } from 'vue';
import { PrimaryButton, ResourcePicker } from '~/components';
import type { Resource } from '~/types';

const MOCK_RESOURCES: Resource[] = [
{
id: 1,
thumbnailUrl: '',
name: 'Apple MacBook Pro',
price: '$2,499.00',
stock: 7,
isChecked: false,
variants: [
{
id: 33,
thumbnailUrl: '',
name: 'Apple MacBook Pro 16 M3 Max',
price: '$3,499.00',
stock: 3,
isChecked: false,
},
{
id: 21,
thumbnailUrl: '',
name: 'Apple MacBook Pro 14 M3 Pro',
price: '$2,499.00',
stock: 4,
isChecked: false,
},
],
},
{
id: 2,
thumbnailUrl: '',
name: 'Apple iMac',
price: '$1,499.00',
stock: 2,
isChecked: false,
},
];

const showPicker = ref(false);
const selectedResources = ref<Resource[]>([]);
const resources = ref<Resource[]>(MOCK_RESOURCES);

const onConfirm = (resources: Resource[]) => {
selectedResources.value = resources;
showPicker.value = false;
};
import { Popover, PrimaryButton, TertiaryButton } from '~/components';
const show = ref(false);
</script>

<template>
<div className="container">
<ResourcePicker
v-model:visible="showPicker"
:resources="resources"
stock-label="in stock"
:is-loading="false"
@confirm="onConfirm"
/>
<PrimaryButton @click="showPicker = true;">
<span>Open Picker</span>
</PrimaryButton>
<div v-if="selectedResources.length > 0" class="selection">
<pre>{{ selectedResources }}</pre>
</div>
<div class="container">
<Popover
v-model:show="show"
position="right"
object-fit="cover"
class="popover"
@click-outside="show = false"
>
<template #title>
Introducing Themes!
</template>
<template #description>
<p class="mr-0">
Introducing themes, a new way to make your store stand out
</p>
</template>
<template #footer>
<div class="actions">
<PrimaryButton @click="show = false">
Get started
</PrimaryButton>
<TertiaryButton @click="show = false">
Later
</TertiaryButton>
</div>
</template>
<PrimaryButton @click="show = !show;">
<span>Show Popover</span>
</PrimaryButton>
</Popover>
</div>
</template>

<style scoped>
.container {
display: flex;
flex-direction: column;
box-sizing: border-box;
align-items: center;
justify-content: center;
max-width: 300px;
gap: 16px;
width: 100vw;
height: 100vh;
padding: 20px;
}

.selection {
padding: 16px;
border: 1px solid var(--gray-200);
border-radius: 8px;
background-color: var(--vp-c-bg);
}

:is(.dark) .selection {
border-color: var(--gray-700);
.actions {
display: flex;
flex-direction: row-reverse;
justify-content: flex-end;
column-gap: 10px;
}
</style>
Loading