Skip to content

Commit 45b86a7

Browse files
committed
refactor: change search button to new component
1 parent 77c6267 commit 45b86a7

2 files changed

Lines changed: 23 additions & 19 deletions

File tree

app/components/Button/Base.vue

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<script setup lang="ts">
2-
const props = defineProps<{
3-
disabled?: boolean
4-
/**
5-
* type should never be used, because this will always be a button.
6-
*
7-
* If you want a link use `TagLink` instead.
8-
* */
9-
type?: never
10-
}>()
2+
const props = withDefaults(
3+
defineProps<{
4+
disabled?: boolean
5+
type?: 'button' | 'submit'
6+
variant?: 'primary' | 'secondary'
7+
}>(),
8+
{
9+
type: 'button',
10+
variant: 'secondary',
11+
},
12+
)
1113
1214
const el = ref<HTMLButtonElement | null>(null)
1315
@@ -19,11 +21,16 @@ defineExpose({
1921
<template>
2022
<button
2123
ref="el"
22-
class="inline-flex items-center justify-center px-4 py-2 font-mono text-sm border border-border rounded-md bg-transparent text-fg transition-all duration-200 hover:(bg-fg hover:text-bg border-fg) focus-ring active:scale-98 disabled:(opacity-40 cursor-not-allowed hover:bg-transparent hover:text-fg)"
23-
:class="{
24-
'opacity-50 cursor-not-allowed': disabled,
25-
}"
26-
type="button"
24+
class="inline-flex gap-x-1 items-center justify-center px-4 py-2 font-mono text-sm border border-border rounded-md transition-all duration-200 focus-ring active:scale-98 disabled:(opacity-40 cursor-not-allowed hover:bg-transparent hover:text-fg)"
25+
:class="[
26+
variant === 'primary'
27+
? 'text-bg bg-fg hover:bg-fg/90'
28+
: 'bg-transparent text-fg hover:(bg-fg hover:text-bg border-fg)',
29+
{
30+
'opacity-50 cursor-not-allowed': disabled,
31+
},
32+
]"
33+
:type="props.type"
2734
:disabled="disabled ? true : undefined"
2835
>
2936
<slot />

app/pages/index.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,10 @@ defineOgImageComponent('Default', {
111111
@input="handleInput"
112112
/>
113113

114-
<button
115-
type="submit"
116-
class="absolute inset-ie-2 px-4 py-2 font-mono text-sm text-bg bg-fg rounded-md transition-[background-color,transform] duration-200 hover:bg-fg/90 active:scale-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50"
117-
>
114+
<ButtonBase type="submit" variant="primary" class="absolute inset-ie-2">
118115
<span class="i-carbon:search align-middle w-4 h-4" aria-hidden="true"></span>
119116
{{ $t('search.button') }}
120-
</button>
117+
</ButtonBase>
121118
</div>
122119
</div>
123120
</form>

0 commit comments

Comments
 (0)