Skip to content

Commit

Permalink
fix: use text decoration underline
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Lebeau committed Oct 27, 2023
1 parent 60c2514 commit e28b4bd
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 13 deletions.
32 changes: 26 additions & 6 deletions packages/components/link/src/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,33 @@ import type { RouteLocationRaw } from 'vue-router'
import type { ExtractPropTypes, PropType } from 'vue'
import type Link from './link.vue'

export enum PuikLinkTarget {
BLANK = '_blank',
SELF = '_self',
PARENT = '_parent',
TOP = '_top',
}

export const targetVariants = ['_blank', '_self', '_parent', '_top'] as const
export type PuikTargetVariant = (typeof targetVariants)[number]
export type PuikTargetString = (typeof targetVariants)[number]

export enum PuikLinkSize {
SMALL = 'sm',
MEDIUM = 'md',
LARGE = 'lg',
}

export const linkSizes = ['sm', 'md', 'lg'] as const
export type PuikLinkSize = (typeof linkSizes)[number]
export type PuikLinkSizeString = (typeof linkSizes)[number]

export const linkProps = buildProps({
size: {
type: String as PropType<PuikLinkSize>,
type: [
String as PropType<PuikLinkSize>,
String as PropType<PuikLinkSizeString>,
],
required: false,
default: 'md',
default: PuikLinkSize.MEDIUM,
},
href: {
type: String,
Expand All @@ -25,9 +42,12 @@ export const linkProps = buildProps({
default: undefined,
},
target: {
type: String as PropType<PuikTargetVariant>,
type: [
String as PropType<PuikLinkTarget>,
String as PropType<PuikTargetString>,
],
required: false,
default: '_self',
default: PuikLinkTarget.SELF,
},
title: {
type: String,
Expand Down
11 changes: 10 additions & 1 deletion packages/components/link/src/link.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,26 @@
:class="['puik-link', `puik-link--${size}`]"
>
<slot></slot>

<span
v-if="props.target === PuikLinkTarget.BLANK"
class="puik-link__target__icon"
>
{{ TARGET_BLANK_ICON }}
</span>
</component>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { linkProps } from './link'
import { linkProps, PuikLinkTarget } from './link'
defineOptions({
name: 'PuikLink',
})
const props = defineProps(linkProps)
const TARGET_BLANK_ICON = 'open_in_new'
const componentType = computed(() => {
if (props.to) {
Expand Down
30 changes: 24 additions & 6 deletions packages/theme/src/link.scss
Original file line number Diff line number Diff line change
@@ -1,29 +1,47 @@
@use './common/typography.scss';

.puik-link {
@apply relative py-[0.5px] text-primary bg-gradient-to-bl from-primary-500 to-primary-500 bg-no-repeat bg-[length:100%_1px] bg-[left_bottom_1.25px] transition-all ease-in-out duration-150;
@apply cursor-pointer
relative
text-primary

underline
decoration-auto
underline-offset-4
decoration-primary-500

transition-all
duration-150;

&:hover,
&:active {
@apply cursor-pointer from-primary-800 to-primary-800 bg-left-bottom transition-all ease-in-out duration-150;
@apply decoration-primary underline-offset-8;
}

&:focus-visible {
@apply outline-none ring-2 ring-blue rounded-[4px] shadow-none;
}

&:visited {
@apply text-purple-700;
}
&[target='_blank'] {
&:after {
content: 'open_in_new';
@apply font-materialIcons ml-1.5 inline-block align-middle leading-[1em];

&__target__icon {
@apply font-materialIcons align-bottom;

&:before {
@apply content-['_'] text-[0.35rem] leading-[0.25rem];
}
}

&--sm {
@extend .puik-body-small;
}

&--md {
@extend .puik-body-default;
}

&--lg {
@extend .puik-body-large;
}
Expand Down

0 comments on commit e28b4bd

Please sign in to comment.