Skip to content

Commit 84b9278

Browse files
committed
feat: add leadingIcon and trailingIcon to BaseButton on /playground
1 parent 06bce6b commit 84b9278

File tree

9 files changed

+312
-34
lines changed

9 files changed

+312
-34
lines changed

frontend/layers/base/app/assets/css/main.css

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ body {
1919
--color-black: #101010;
2020

2121
--color-brand-300: #6482EC;
22+
--color-brand-500: #1E46D6;
23+
--color-brand-700: #172F81;
2224

2325
--color-white: #FAFAFA;
2426
--color-gray-100: #D6D6D6;
@@ -32,9 +34,15 @@ body {
3234
--spacing-sm: .375rem; /* 6px */
3335
--spacing-md: .5rem; /* 8px */
3436
--spacing-lg: .75rem; /* 12px */
35-
36-
--text-sm: .875rem; /* 14px */
37-
--text-sm--line-height: 1.25rem; /* 20px */
37+
--spacing-xl: 1rem; /* 16px */
38+
--spacing-3xl: 1.5rem; /* 24px */
39+
40+
--text-sm-tight: .875rem; /* 14px */
41+
--text-sm-tight--line-height: 1rem; /* 16px */
42+
/* --text-sm: .875rem; 14px */
43+
/* --text-sm--line-height: 1.25rem; 20px */
44+
--text-md: 1rem; /* 16px */
45+
--text-md--line-height: 1.5rem; /* 24px */
3846

3947
}
4048
/* todo: think about moving this to theme.css (problem import order) */
Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,40 @@
11
<script setup lang="ts">
2-
const { variant = 'primary' } = defineProps<{
3-
variant?: 'primary' | 'secondary',
2+
import { LazyBaseIcon } from '#components'
3+
import type { IconName } from '~/layers/base/app/components/BaseIcon.vue'
4+
5+
const {
6+
size = 'md',
7+
variant = 'primary',
8+
} = defineProps<{
9+
leadingIcon?: IconName,
10+
size?: 'md' | 'xl',
11+
trailingIcon?: IconName,
12+
variant?: 'branded' | 'primary',
413
}>()
514
</script>
615

716
<template>
817
<button
9-
class="bg-linear-to-b py-md px-sm rounded-full text-sm font-semibold opacity-90 hover:opacity-95 disabled:opacity-40 aria-disabled:opacity-40 active:opacity-80 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand-300"
18+
class="flex items-center bg-linear-to-b rounded-full font-semibold disabled:opacity-40 aria-disabled:opacity-40 active:opacity-80 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand-300"
1019
:class="[
11-
variant === 'primary' && 'from-gray-100 to-gray-300 text-black',
20+
variant === 'primary' && 'from-gray-100 to-gray-300 text-black opacity-90 hover:opacity-95',
21+
variant === 'branded' && 'from-brand-500 to-brand-700 text-white hover:opacity-90',
22+
size === 'md' && 'text-sm-tight py-md px-sm',
23+
size === 'xl' && 'text-md py-xl px-3xl',
1224
]"
1325
>
26+
<LazyBaseIcon
27+
v-if="leadingIcon"
28+
:name="leadingIcon"
29+
class=""
30+
/>
1431
<span class="px-lg">
1532
<slot />
1633
</span>
34+
<LazyBaseIcon
35+
v-if="trailingIcon"
36+
:name="trailingIcon"
37+
class=""
38+
/>
1739
</button>
1840
</template>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<script setup lang="ts">
2+
import type icons from '@iconify-json/tabler/icons.json'
3+
4+
export type IconName = keyof typeof icons['icons']
5+
6+
const { name } = defineProps<{
7+
name: IconName,
8+
}>()
9+
const customize = (content: string) => {
10+
return content
11+
.replace(/stroke-width="[^"]*"/g, 'stroke-width="1.5px"')
12+
}
13+
</script>
14+
15+
<template>
16+
<Icon
17+
:name="`tabler:${name}`"
18+
:customize
19+
/>
20+
</template>

frontend/layers/base/app/layouts/base.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts"></script>
22

33
<template>
4-
<div class="font-urbanist">
4+
<div class="font-urbanist antialiased">
55
<slot />
66
</div>
77
</template>

frontend/layers/base/app/pages/test.vue renamed to frontend/layers/base/app/pages/playground/index.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@
66
<NuxtLayout name="base">
77
Primary Button
88
<section class="grid gap-sm">
9+
<div>
10+
<BaseButton
11+
leading-icon="file-code-2"
12+
trailing-icon="arrow-up-right"
13+
size="xl"
14+
variant="branded"
15+
>
16+
Go to API
17+
</BaseButton>
18+
</div>
919
<div>
1020
<BaseButton
1121
variant="primary"

frontend/layers/base/nuxt.config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,20 @@ import tailwindcss from '@tailwindcss/vite'
77
const currentDir = dirname(fileURLToPath(import.meta.url))
88

99
export default defineNuxtConfig({
10+
/* eslint-disable perfectionist/sort-objects -- as there is a conflict with `nuxt specific eslint rules` */
11+
modules: [ '@nuxt/icon' ],
1012
$meta: {
1113
name: 'base',
1214
},
1315
css: [ join(currentDir, './app/assets/css/main.css') ],
1416
vite: {
1517
plugins: [ tailwindcss() ],
1618
},
19+
icon: {
20+
mode: 'css',
21+
cssLayer: 'base',
22+
size: '1.25rem',
23+
localApiEndpoint: '/api/bff/_nuxt_icon',
24+
},
25+
/* eslint-enable perfectionist/sort-objects */
1726
})

frontend/layers/base/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
"@tailwindcss/vite": "^4.1.12",
44
"tailwindcss": "^4.1.12"
55
},
6+
"devDependencies": {
7+
"@iconify-json/tabler": "^1.2.22",
8+
"@nuxt/icon": "^2.0.0"
9+
},
610
"name": "beaconchain-explorer-base",
711
"private": true,
812
"type": "module"

frontend/middleware/redirect.global.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { RouteLocationNormalizedLoaded } from 'vue-router'
33
export default function ({
44
name,
55
params,
6+
path,
67
}: RouteLocationNormalizedLoaded) {
78
const { has } = useFeatureFlag()
89
const config = useRuntimeConfig()
@@ -62,4 +63,8 @@ export default function ({
6263
case 'validator-id':
6364
return redirectToV1(`/validator/${params.id || params.slug?.[1]}`)
6465
}
66+
const currentEnvironment = config.public.deploymentType
67+
if (currentEnvironment === 'production' && path.startsWith('/playground')) {
68+
return abortNavigation()
69+
}
6570
}

0 commit comments

Comments
 (0)