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

Solving issue #19 feat: improve existing button components #21

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ You can use the components in your Vue templates like this:

```ts
<template>
<HoppButtonPrimary label="Click me" />
<HoppButton label="Click me" />
</template>

<script lang="ts" setup>
import { HoppButtonPrimary } from "@hoppscotch/ui"
import { HoppButton } from "@hoppscotch/ui"
</script>
```

If you're using `unplugin-vue-components` in your project, you can import the components like this without having to import them in the script section:

```ts
<template>
<HoppButtonPrimary label="Click me" />
<HoppButton label="Click me" />
</template>

<script lang="ts" setup>
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,6 @@
"types": "./dist/src/helpers/index.d.ts"
}
},
"types": "./dist/index.d.ts"
"types": "./dist/index.d.ts",
"packageManager": "[email protected]+sha256.dbdf5961c32909fb030595a9daa1dae720162e658609a8f92f2fa99835510ca5"
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
<template>
<HoppSmartLink
:to="to"
:blank="blank"
class="relative inline-flex items-center justify-center py-2 font-semibold whitespace-nowrap transition focus:outline-none focus-visible:bg-accentDark"
:exact="exact"
:blank="blank"
class="relative inline-flex items-center justify-center whitespace-nowrap py-2 font-semibold transition focus:outline-none focus-visible:bg-accentDark"
:class="[
color
color && type === 'primary'
? `text-${color}-800 bg-${color}-200 hover:(text-${color}-900 bg-${color}-300) focus-visible:(text-${color}-900 bg-${color}-300)`
: `bg-accent text-accentContrast hover:bg-accentDark focus-visible:bg-accentDark`,
: '',
color && type === 'secondary'
? `text-${color}-500 hover:text-${color}-600 focus-visible:text-${color}-600`
: '',
{
'bg-accent text-accentContrast hover:bg-accentDark focus-visible:bg-accentDark':
type === 'primary' && !color,
},
{
'text-secondary hover:text-secondaryDark focus-visible:text-secondaryDark':
type === 'secondary' && !color,
},
label ? 'px-4 py-2' : 'p-2',
rounded ? 'rounded-full' : 'rounded',
{ 'cursor-not-allowed opacity-75': disabled },
Expand Down Expand Up @@ -83,6 +94,7 @@ interface Props {
gradient?: boolean
outline?: boolean
shortcut?: string[]
type?: "primary" | "secondary"
}

withDefaults(defineProps<Props>(), {
Expand All @@ -102,5 +114,6 @@ withDefaults(defineProps<Props>(), {
gradient: false,
outline: false,
shortcut: () => [],
type: "primary",
})
</script>
99 changes: 0 additions & 99 deletions src/components/button/Secondary.vue

This file was deleted.

3 changes: 1 addition & 2 deletions src/components/button/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default as HoppButtonPrimary } from "./Primary.vue"
export { default as HoppButtonSecondary } from "./Secondary.vue"
export { default as HoppButton } from "./Button.vue"
4 changes: 2 additions & 2 deletions src/components/modal/Heading.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</h3>
</div>
<div class="flex flex-1 items-center justify-end">
<HoppButtonSecondary
<HoppButton
v-if="showCloseIcon"
v-tippy="{ theme: 'tooltip', delay: [500, 20] }"
:title="closeText ?? t?.('action.close') ?? 'Close'"
Expand All @@ -27,7 +27,7 @@
import { inject } from "vue"
import { HOPP_UI_OPTIONS, HoppUIPluginOptions } from "./../../plugin"
import IconX from "~icons/lucide/x"
import { HoppButtonSecondary } from "./../button"
import { HoppButton } from "./../button"

const { t } = inject<HoppUIPluginOptions>(HOPP_UI_OPTIONS) ?? {}

Expand Down
10 changes: 2 additions & 8 deletions src/components/modal/examples/InputDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,10 @@
/>
</template>
<template #footer>
<HoppButtonPrimary
<HoppButton
label="Submit"
@click="emit('modal-resolve', { text })"
/>
<HoppButtonSecondary
filled
label="Cancel"
@click="emit('modal-reject')"
/>
</template>
</HoppModal>
</template>
Expand All @@ -30,8 +25,7 @@ import { ref } from "vue"
import { HoppModal } from "./../"
import {
HoppSmartInput,
HoppButtonSecondary,
HoppButtonPrimary,
HoppButton,
} from "./../../index"

const text = ref<string>("")
Expand Down
8 changes: 3 additions & 5 deletions src/components/modal/examples/NestedDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<HoppModal title="Dialog with Input field" @close="emit('modal-reject')">
<template #body>
<div>
<HoppButtonSecondary
<HoppButton
label="Open Nested Dialog with Input"
@click="openNestedInputDialog"
/>
Expand All @@ -16,11 +16,10 @@
</div>
</template>
<template #footer>
<HoppButtonPrimary
<HoppButton
label="Submit from Parent"
@click="emit('modal-resolve', { text })"
/>
<HoppButtonSecondary label="Cancel" @click="emit('modal-reject')" />
</template>
</HoppModal>
</template>
Expand All @@ -29,8 +28,7 @@
import { ref } from "vue"
import { HoppModal } from "./../"
import {
HoppButtonPrimary,
HoppButtonSecondary,
HoppButton,
HoppSmartInput,
} from "./../../index"

Expand Down
10 changes: 2 additions & 8 deletions src/components/smart/ConfirmModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,21 @@
</template>
<template #footer>
<span class="flex space-x-2">
<HoppButtonPrimary
<HoppButton
v-focus
:label="yes ?? t?.('action.yes') ?? 'Yes'"
:loading="!!loadingState"
outline
@click="resolve"
/>
<HoppButtonSecondary
:label="no ?? t?.('action.no') ?? 'No'"
filled
outline
@click="hideModal"
/>
</span>
</template>
</HoppSmartModal>
</template>

<script setup lang="ts">
import { inject } from "vue"
import { HoppButtonPrimary, HoppButtonSecondary } from "../button"
import { HoppButton } from "../button"
import { HoppSmartModal } from "."
import { HoppUIPluginOptions, HOPP_UI_OPTIONS } from "./../../plugin"

Expand Down
4 changes: 2 additions & 2 deletions src/components/smart/Expand.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div
class="sticky inset-x-0 bottom-0 flex items-center justify-center flex-shrink-0 overflow-x-auto"
>
<HoppButtonSecondary
<HoppButton
:icon="expand ? IconChevronUp : IconChevronDown"
:label="
expand
Expand All @@ -23,7 +23,7 @@
</template>

<script setup lang="ts">
import { HoppButtonSecondary } from "../button"
import { HoppButton } from "../button"
import IconChevronUp from "~icons/lucide/chevron-up"
import IconChevronDown from "~icons/lucide/chevron-down"
import { inject, ref } from "vue"
Expand Down
4 changes: 2 additions & 2 deletions src/components/smart/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</h3>
</div>
<div class="flex items-center justify-end flex-1">
<HoppButtonSecondary
<HoppButton
v-if="dimissible"
v-tippy="{ theme: 'tooltip', delay: [500, 20] }"
:title="closeText ?? t?.('action.close') ?? 'Close'"
Expand Down Expand Up @@ -95,7 +95,7 @@ const stack = (() => {
</script>

<script setup lang="ts">
import { HoppButtonSecondary } from "../button"
import { HoppButton } from "../button"
import IconX from "~icons/lucide/x"
import {
ref,
Expand Down
4 changes: 2 additions & 2 deletions src/components/smart/SlideOver.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
>
<h3 class="ml-4 heading">{{ title }}</h3>
<span class="flex items-center">
<HoppButtonSecondary :icon="IconX" @click="close()" />
<HoppButton :icon="IconX" @click="close()" />
</span>
</div>
<slot name="content"></slot>
Expand All @@ -33,7 +33,7 @@
</template>

<script setup lang="ts">
import { HoppButtonSecondary } from "../button"
import { HoppButton } from "../button"
import { onMounted, watch } from "vue"
import IconX from "~icons/lucide/x"

Expand Down
6 changes: 3 additions & 3 deletions src/components/smart/Windows.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<component :is="tabMeta.suffix" />
</div>

<HoppButtonSecondary
<HoppButton
v-if="tabMeta.isRemovable"
v-tippy="{ theme: 'tooltip', delay: [500, 20] }"
:icon="IconX"
Expand Down Expand Up @@ -87,7 +87,7 @@
v-if="canAddNewTab"
class="z-[8] flex h-full items-center justify-center bg-primaryLight px-3"
>
<HoppButtonSecondary
<HoppButton
v-tippy="{ theme: 'tooltip' }"
:title="newText ?? t?.('action.new') ?? 'New'"
:icon="IconPlus"
Expand Down Expand Up @@ -129,7 +129,7 @@
</template>

<script setup lang="ts">
import { HoppButtonSecondary } from "../button"
import { HoppButton } from "../button"
import IconPlus from "~icons/lucide/plus"
import IconX from "~icons/lucide/x"
import { pipe } from "fp-ts/function"
Expand Down
6 changes: 3 additions & 3 deletions src/stories/Button.story.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<template>
<Story title="Button">
<Variant title="Primary">
<HoppButtonPrimary label="Button" />
<HoppButton label="Primary Button" />
</Variant>
<Variant title="Secondary">
<HoppButtonSecondary label="Button" />
<HoppButton type="secondary" :outline="true" label="Secondary Button" />
</Variant>
</Story>
</template>

<script setup lang="ts">
import { HoppButtonPrimary, HoppButtonSecondary } from "../components/button"
import { HoppButton } from "../components/button"
</script>
Loading