File tree Expand file tree Collapse file tree 3 files changed +52
-0
lines changed
packages/storefront-ui/src/components/SfLink Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ import { Slot , component$ } from '@builder.io/qwik' ;
2+ import { SfLinkVariant } from '../../shared' ;
3+ import { SfLinkProps } from './types' ;
4+
5+ const defaultLinkTag = 'a' ;
6+
7+ export const SfLink = component$ < SfLinkProps > (
8+ ( {
9+ as,
10+ ref,
11+ class : _class ,
12+ variant = SfLinkVariant . primary ,
13+ ...attributes
14+ } ) => {
15+ const variantClasses = {
16+ [ SfLinkVariant . primary ] :
17+ 'text-primary-700 underline hover:text-primary-800 active:text-primary-900' ,
18+ [ SfLinkVariant . secondary ] :
19+ 'underline hover:text-primary-800 active:text-primary-900' ,
20+ } ;
21+ const Tag = as || defaultLinkTag ;
22+
23+ return (
24+ < Tag
25+ { ...( ref ? { ref } : { } ) }
26+ class = { [
27+ 'focus-visible:outline focus-visible:outline-offset focus-visible:rounded-sm' ,
28+ variantClasses [ variant ] ,
29+ _class ,
30+ ] }
31+ data-testid = "link"
32+ { ...attributes }
33+ >
34+ < Slot />
35+ </ Tag >
36+ ) ;
37+ }
38+ ) ;
39+
40+ export default SfLink ;
Original file line number Diff line number Diff line change 1+ export * from './types' ;
2+
3+ export { SfLink } from './SfLink' ;
Original file line number Diff line number Diff line change 1+ import { QwikIntrinsicElements , Signal } from '@builder.io/qwik' ;
2+ import { SfLinkVariant } from '../../shared' ;
3+
4+ export type SfLinkProps = QwikIntrinsicElements [ 'a' ] & {
5+ as ?: any ;
6+ ref ?: Signal < Element | undefined > ;
7+ class ?: string ;
8+ variant ?: `${SfLinkVariant } `;
9+ } ;
You can’t perform that action at this time.
0 commit comments