Skip to content

Commit f1ec9fb

Browse files
committed
add SfLink
1 parent edb455d commit f1ec9fb

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './types';
2+
3+
export { SfLink } from './SfLink';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
};

0 commit comments

Comments
 (0)