@loomhq/lens 10.34.0 → 10.34.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
declare const LinkWrapper: import("@emotion/styled-base").StyledComponent<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, LinkWrapperProps, object>;
|
|
3
|
-
declare const Link: ({ children, href, variant, ...props }: LinkProps & React.ComponentProps<typeof LinkWrapper>) => JSX.Element;
|
|
3
|
+
declare const Link: ({ children, href, variant, htmlTag, isDisabled, ...props }: LinkProps & React.ComponentProps<typeof LinkWrapper>) => JSX.Element;
|
|
4
4
|
export declare const availableVariants: string[];
|
|
5
5
|
declare type LinkProps = {
|
|
6
6
|
children?: React.ReactNode;
|
|
7
7
|
href?: string;
|
|
8
8
|
variant?: 'neutral' | 'primary';
|
|
9
|
+
htmlTag?: 'button' | 'a';
|
|
10
|
+
isDisabled?: boolean;
|
|
9
11
|
onClick?: React.ReactEventHandler;
|
|
10
12
|
};
|
|
11
13
|
declare type LinkWrapperProps = {
|
|
12
14
|
children?: React.ReactNode;
|
|
13
15
|
href?: string;
|
|
16
|
+
disabled?: boolean;
|
|
14
17
|
variant?: 'neutral' | 'primary';
|
|
18
|
+
as?: string;
|
|
15
19
|
};
|
|
16
20
|
export default Link;
|
|
@@ -11,6 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import React from 'react';
|
|
13
13
|
import styled from '@emotion/styled';
|
|
14
|
+
import { css } from '@emotion/core';
|
|
14
15
|
import { getColorValue } from '../../utilities';
|
|
15
16
|
const variants = {
|
|
16
17
|
neutral: {
|
|
@@ -20,16 +21,33 @@ const variants = {
|
|
|
20
21
|
color: getColorValue('primary'),
|
|
21
22
|
},
|
|
22
23
|
};
|
|
24
|
+
const statusStyles = {
|
|
25
|
+
enabled: css `
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
`,
|
|
28
|
+
disabled: css `
|
|
29
|
+
pointer-events: none;
|
|
30
|
+
color: ${getColorValue('disabledContent')};
|
|
31
|
+
`,
|
|
32
|
+
};
|
|
33
|
+
const buttonStyles = {
|
|
34
|
+
isButton: css `
|
|
35
|
+
background: none;
|
|
36
|
+
border: none;
|
|
37
|
+
font: inherit;
|
|
38
|
+
`
|
|
39
|
+
};
|
|
23
40
|
const LinkWrapper = styled.a `
|
|
24
41
|
text-decoration: none;
|
|
25
|
-
|
|
42
|
+
${props => !props.disabled && `color: ${variants[props.variant].color}`};
|
|
26
43
|
box-shadow: 0 1px 0 currentColor;
|
|
27
|
-
padding
|
|
28
|
-
|
|
44
|
+
padding: 0 0 1px 0;
|
|
45
|
+
${props => props.disabled ? statusStyles.disabled : statusStyles.enabled};
|
|
46
|
+
${props => props.as === 'button' && buttonStyles.isButton};
|
|
29
47
|
`;
|
|
30
48
|
const Link = (_a) => {
|
|
31
|
-
var { children, href, variant = 'primary' } = _a, props = __rest(_a, ["children", "href", "variant"]);
|
|
32
|
-
return (React.createElement(LinkWrapper, Object.assign({ href: href, variant: variant }, props), children));
|
|
49
|
+
var { children, href, variant = 'primary', htmlTag = 'a', isDisabled } = _a, props = __rest(_a, ["children", "href", "variant", "htmlTag", "isDisabled"]);
|
|
50
|
+
return (React.createElement(LinkWrapper, Object.assign({ href: href, variant: variant, as: htmlTag, disabled: isDisabled }, props), children));
|
|
33
51
|
};
|
|
34
52
|
export const availableVariants = Object.keys(variants);
|
|
35
53
|
export default Link;
|