Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# vueish
Vue UI Library

Install:
- add `style="position: relative"` to the body tag
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Vite App</title>
</head>
<body>
<div id="app" class="h-full">
<div id="app" class="h-full relative">
</div>
<script type="module" src="/src/demo.ts"></script>
</body>
Expand Down
3,688 changes: 2,501 additions & 1,187 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@vitejs/plugin-vue": "^1.0.4",
"@vue/compiler-sfc": "^3.0.5",
"@vue/eslint-config-typescript": "^7.0.0",
"@vue/test-utils": "^2.0.0-beta.14",
"@vue/test-utils": "^2.0.0-rc.2",
"@vuedx/typecheck": "^0.6.3",
"@vuedx/typescript-plugin-vue": "^0.6.3",
"autoprefixer": "^10.2.3",
Expand All @@ -56,5 +56,8 @@
"vue-loader": "^16.1.2",
"vue-router": "^4.0.3",
"vue-template-compiler": "^2.6.12"
},
"dependencies": {
"vue3-click-away": "^1.1.0"
}
}
1 change: 1 addition & 0 deletions src/components/panel/UIPanel.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<section :id="id"
class="ui-panel rounded shadow-md bg-default relative transition-all"
:aria-expanded="open"
:class="{ 'hover:shadow-lg': !open }">
<UIFadeTransition>
<UILinearLoader v-if="loading" class="absolute rounded-t" />
Expand Down
9 changes: 6 additions & 3 deletions src/components/radio/UIRadio.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { DOMWrapper } from '@vue/test-utils';
import UIRadio from './UIRadio.vue';
import UIRadioGroup from './UIRadioGroup.vue';
import { disableConsoleWarn, enableConsoleWarn } from '@helpers/test';
import { h } from 'vue';

describe('UIRadio', () => {
it('should bind attributes to the input', () => {
Expand Down Expand Up @@ -192,16 +193,18 @@ describe('UIRadioGroup', () => {
}
});

const radioGroup = wrapper.findComponent(UIRadioGroup);
const input = wrapper.find('input[type="radio"]');

await input.trigger('click');
expect(wrapper.emitted()).toHaveProperty('update:modelValue');
expect(wrapper.emitted()['update:modelValue'][0]).toStrictEqual(['foo']);
expect(radioGroup.emitted('update:modelValue')).not.toBeUndefined();
expect(radioGroup.emitted('update:modelValue')![0]).toStrictEqual(['foo']);
});

it('should throw an error if there are missing UIRadio components', () => {
disableConsoleWarn();
expect(() => mount(UIRadioGroup)).toThrow('UIRadioGroup requires at least 2 UIRadio components present');
expect(() => mount(UIRadioGroup))
.toThrow('UIRadioGroup requires at least 2 UIRadio components in the default slot.');
enableConsoleWarn();
});
});
3 changes: 2 additions & 1 deletion src/components/radio/UIRadioGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default defineComponent({
setup(props, ctx) {
const slot = ref<HTMLDivElement>();
const watchStopHandlers: ReturnType<typeof watch>[] = [];

const updateInputs = () => {
watchStopHandlers.forEach(stop => stop());
watchStopHandlers.length = 0;
Expand All @@ -48,7 +49,7 @@ export default defineComponent({

// Validate they exist
if (!inputs || inputs.length < 2) {
throw Error('UIRadioGroup requires at least 2 UIRadio components present.');
throw Error('UIRadioGroup requires at least 2 UIRadio components in the default slot.');
}

const setChecked = (input: HTMLInputElement) => input.checked = props.modelValue === input.value;
Expand Down
57 changes: 57 additions & 0 deletions src/components/select/Demo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<template>
<UISelect v-model="selected"
:options="options"
placeholder="Please select..." />

<UISelect v-model="multiSelected"
multi
class="my-12"
:options="options"
placeholder="Please select..." />

<UISelect v-model="multiSelected"
multi
disabled
:options="options"
placeholder="Please select..." />
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';
import UISelect from '@components/select/UISelect.vue';

const options = [
{
id: 1,
name: 'Bruce Banner'
},
{
id: 2,
name: 'Bruce Wayne'
},
{
id: 3,
name: 'Bruce Lee'
},
{
id: 4,
name: 'Brucie Bonus'
}
];

export default defineComponent({
// eslint-disable-next-line vue/no-reserved-component-names
name: 'Select',
components: { UISelect },
setup() {
const selected = ref(null);
const multiSelected = ref(null);

return {
selected,
multiSelected,
options
};
}
});
</script>
Loading