Skip to content

Commit

Permalink
feat: add color picker and fix documents routes
Browse files Browse the repository at this point in the history
  • Loading branch information
DomeT99 committed Jul 7, 2024
1 parent c05fee0 commit 46eaaa7
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 11 deletions.
1 change: 1 addition & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default defineConfig({
items: [
{ text: "EButton", link: "../components/ebutton.md" },
{ text: "ECheckbox", link: "../components/echeckbox.md" },
{ text: "EColorPicker", link: "../components/ecolorpicker.md" },
{ text: "EDatePicker", link: "../components/edatepicker.md" },
{ text: "EText", link: "../components/etext.md" },
{ text: "ETextArea", link: "../components/etextarea.md" },
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/components/echeckbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ prev:
text: "EButton"
link: "/guide/components/ebutton.md"
next:
text: "EText"
link: "/guide/components/etext.md"
text: "EColorPicker"
link: "/guide/components/ecolorpicker.md"
---

<script setup lang="ts">
Expand Down
52 changes: 52 additions & 0 deletions docs/guide/components/ecolorpicker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
prev:
text: "ECheckbox"
link: "/guide/components/echeckbox.md"
next:
text: "EDatePicker"
link: "/guide/components/edatepicker.md"
---

<script setup lang="ts">
import { EColorPicker } from "../../../src/index.ts";
import ExampleLayout from "../../utils/ExampleLayout.vue";
import { ref } from "vue";

const color = ref();
</script>

# EColorPicker

The `EColorPicker` component replaces the standard html input type color and encapsulates well-defined logic that can be reused throughout the app.

## Basic Usage

```vue-html
<script setup>
import { ref } from "vue";
import { EColorPicker } from "easy-kit-component";
const date = ref();
</script>
<template>
<EColorPicker v-model="color"/>
</template>
```

<ExampleLayout>
<EColorPicker style="width: 40px !important" id="text" v-model="color"/>
<br/>
<h6>Color is : {{ color }}</h6>
</ExampleLayout>


## API Reference

- **Props**

```ts
interface ColorPicker {
disabled?: boolean;
}
```
4 changes: 2 additions & 2 deletions docs/guide/components/edatepicker.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
prev:
text: "ECheckbox"
link: "/guide/components/echeckbox.md"
text: "EColorPicker"
link: "/guide/components/ecolorpicker.md"
next:
text: "EText"
link: "/guide/components/etext.md"
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/components/eradio.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
prev:
text: "EText"
link: "/guide/components/etext.md"
text: "ETextArea"
link: "/guide/components/etextarea.md"
next:
text: "ESelect"
link: "/guide/components/eselect.md"
Expand Down
8 changes: 4 additions & 4 deletions docs/guide/components/etext.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
prev:
text: "ECheckbox"
link: "/guide/components/echeckbox.md"
text: "EDatePicker"
link: "/guide/components/edatepicker.md"
next:
text: "ERadio"
link: "/guide/components/eradio.md"
text: "ETextArea"
link: "/guide/components/etextarea.md"
---

<script setup lang="ts">
Expand Down
15 changes: 15 additions & 0 deletions src/components/input/colorpicker/EColorPicker.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { shallowMount } from "@vue/test-utils";
import { describe, it, expect } from "vitest";
import EColorPicker from "./EColorPicker.vue";

describe("EColorPicker suite", () => {
let wrapper = shallowMount(EColorPicker);

it("render correctly", () => {
expect(wrapper.html()).toMatchSnapshot();
});

it("render default disabled", () => {
expect(wrapper.attributes("disabled")).toBeUndefined();
});
});
24 changes: 24 additions & 0 deletions src/components/input/colorpicker/EColorPicker.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<script setup lang="ts">
import { useUpdateModelText } from "../../../composables/useUpdateModelValue";
interface ColorPicker {
disabled?: boolean;
}
const props = defineProps<ColorPicker>();
const emit = defineEmits();
</script>

<template>
<input
type="color"
@input="useUpdateModelText($event, emit)"
:disabled="props.disabled"
/>
</template>

<script lang="ts">
export default {
name: "EColorPicker",
};
</script>
12 changes: 11 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import EButton from "./components/button/EButton.vue";
import ECheckbox from "./components/input/checkbox/ECheckbox.vue";
import EColorPicker from "./components/input/colorpicker/EColorPicker.vue";
import EDatePicker from "./components/input/datepicker/EDatePicker.vue";
import EText from "./components/input/text/EText.vue";
import ETextArea from "./components/input/textarea/ETextArea.vue";
import ERadio from "./components/radio/ERadio.vue";
import ESelect from "./components/select/ESelect.vue";

export { EButton, ECheckbox, EDatePicker, EText, ETextArea, ERadio, ESelect };
export {
EButton,
ECheckbox,
EColorPicker,
EDatePicker,
EText,
ETextArea,
ERadio,
ESelect,
};

0 comments on commit 46eaaa7

Please sign in to comment.