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-433: Removed defineAsyncComponent and Use Component Directly #384

Merged
merged 2 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
with:
node-version: 20.9.0

- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v4
name: install pnpm
with:
version: 8.10.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
node-version: 20.9.0

- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v4
name: install pnpm
with:
version: 8.10.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/storybook-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
with:
node-version: 20.9.0

- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v4
name: install pnpm
with:
version: 8.10.0
Expand Down
37 changes: 9 additions & 28 deletions packages/alto/src/_dev/App.vue
Original file line number Diff line number Diff line change
@@ -1,44 +1,25 @@
<script setup lang="ts">
import 'uno.css';
import '../assets/main.css';
import { ref } from 'vue';
import type { TagItemValue } from '../types';
import { ColorInput, ColorPicker, Tag } from '~/components';

const colorv3 = ref('#A8B1FFFF');
const color = ref('#A8B1FFFF');

function updateColor(newColor: string) {
color.value = newColor;
}

const preferredLanguages = ref<TagItemValue[]>([
{ label: 'Pink', hexColor: '#F49FBC' },
]);
import { Loader } from '~/components';
</script>

<template>
<div class="container">
<Tag
v-model="preferredLanguages"
placeholder="Your favorite colors"
type="color"
/>
<ColorInput :model-value="color" @update:modelValue="updateColor" />
</div>
<div class="container">
<ColorPicker :preserve-transparency="false" :model-value="colorv3" />
<ColorPicker :model-value="colorv3" />
<Loader variant="spinner" label="Loading..." />
<Loader variant="brand" />
<Loader variant="bar" />
</div>
</template>

<style scoped>
.container {
display: flex;
flex-direction: row;
margin: 30px;
padding: 10%;
background-color: var(--gray-200);
gap: 0.5rem;
align-items: center;
justify-content: center;
width: 100vw;
height: 100vh;
gap: 80px;
}
</style>
21 changes: 5 additions & 16 deletions packages/alto/src/components/Loader/Loader.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import { computed, defineAsyncComponent } from 'vue';
import { Bar, Brand, Spinner } from './internal';
import type { LoaderProps } from '~/types';

const props = withDefaults(
withDefaults(
defineProps<LoaderProps>(),
{
color: 'var(--brand-500)',
Expand All @@ -12,24 +12,13 @@ const props = withDefaults(
variant: 'spinner',
},
);

const loader = computed (() => {
switch (props.variant) {
case 'brand':
return defineAsyncComponent(() => import('./internal/BrandLoading.vue'));

case 'bar':
return defineAsyncComponent(() => import('./internal/BarLoading.vue'));

default:
return defineAsyncComponent(() => import('./internal/Spinner.vue'));
}
});
</script>

<template>
<div class="loader-block">
<component :is="loader" :color="color" :size="size" />
<Bar v-if="variant === 'bar'" v-bind="{ color, size }" />
<Brand v-else-if="variant === 'brand'" v-bind="{ color, size }" />
<Spinner v-else v-bind="{ color, size }" />

<p v-if="label" class="label" :class="[labelFontSize]">
{{ label }}
Expand Down
3 changes: 3 additions & 0 deletions packages/alto/src/components/Loader/internal/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { default as Bar } from './Bar.vue';
export { default as Brand } from './Brand.vue';
export { default as Spinner } from './Spinner.vue';
Loading