@frank-auth/react
Version:
Flexible and customizable React UI components for Frank Authentication
120 lines (104 loc) • 4.46 kB
JavaScript
'use client';
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),S=require("../../../theme/context.cjs"),a=require("../../../theme/styled.cjs"),o=require("@emotion/react"),w=require("@emotion/styled"),z=require("react"),h=e=>e&&e.__esModule?e:{default:e},p=h(w),L=h(z),j=e=>{const{theme:t,color:r="primary",variant:u="solid",isDisabled:d}=e;if(d)return o.css`
color: ${t.colors.text.tertiary};
cursor: not-allowed;
pointer-events: none;
opacity: 0.5;
`;if(r==="foreground")return o.css`
color: ${t.colors.text.primary};
&:hover {
opacity: 0.8;
}
&:active {
opacity: 0.6;
}
`;const s=a.getColorVariant(t,r,500),n=a.getColorVariant(t,r,600),l=a.getColorVariant(t,r,700),f=a.getColorVariant(t,r,50);switch(u){case"solid":return o.css`
color: ${s};
&:hover {
color: ${n};
}
&:active {
color: ${l};
}
`;case"underlined":return o.css`
color: ${s};
text-decoration: underline;
text-underline-offset: 2px;
&:hover {
color: ${n};
}
&:active {
color: ${l};
}
`;case"light":return o.css`
color: ${s};
background-color: transparent;
padding: ${t.spacing[1]} ${t.spacing[2]};
border-radius: ${t.borderRadius.sm};
&:hover {
background-color: ${f};
}
&:active {
background-color: ${a.getColorVariant(t,r,100)};
}
`;default:return o.css``}},_=e=>{const{theme:t,size:r="md"}=e;switch(r){case"sm":return o.css`
font-size: ${t.fontSizes.sm};
`;case"md":return o.css`
font-size: ${t.fontSizes.base};
`;case"lg":return o.css`
font-size: ${t.fontSizes.lg};
`;default:return o.css`
font-size: ${t.fontSizes.base};
`}},q=e=>{const{underline:t="hover"}=e;switch(t){case"none":return o.css`
text-decoration: none;
&:hover {
text-decoration: none;
}
`;case"hover":return o.css`
text-decoration: none;
&:hover {
text-decoration: underline;
text-underline-offset: 2px;
}
`;case"always":return o.css`
text-decoration: underline;
text-underline-offset: 2px;
`;case"active":return o.css`
text-decoration: none;
&:active {
text-decoration: underline;
text-underline-offset: 2px;
}
`;case"focus":return o.css`
text-decoration: none;
&:focus {
text-decoration: underline;
text-underline-offset: 2px;
}
`;default:return o.css``}},R=p.default.a`
display: ${e=>e.isBlock?"block":"inline-flex"};
align-items: center;
gap: ${e=>e.theme.spacing[1]};
font-family: inherit;
font-weight: ${e=>e.theme.fontWeights.medium};
line-height: ${e=>e.theme.lineHeights.normal};
cursor: pointer;
transition: all ${e=>e.theme.transitions.fast};
position: relative;
outline: none;
&:focus-visible {
outline: 2px solid ${e=>e.theme.colors.border.focus};
outline-offset: 2px;
border-radius: ${e=>e.theme.borderRadius.sm};
}
${j}
${_}
${q}
/* Custom CSS prop */
${e=>e.css}
`,V=p.default.svg`
width: ${e=>{switch(e.size){case"sm":return"12px";case"lg":return"18px";default:return"14px"}}};
height: ${e=>{switch(e.size){case"sm":return"12px";case"lg":return"18px";default:return"14px"}}};
opacity: 0.7;
`,g=L.default.forwardRef(({children:e,color:t="primary",size:r="md",underline:u="hover",variant:d="solid",isExternal:s=!1,isDisabled:n=!1,isBlock:l=!1,className:f,css:m,href:i,target:$,rel:v,...y},k)=>{const{theme:b}=S.useTheme(),x=s||i&&(i.startsWith("http")||i.startsWith("mailto:")||i.startsWith("tel:")),C={...y,color:t,size:r,underline:u,variant:d,isDisabled:n,isBlock:l,className:f,css:m,href:n?void 0:i,target:x?"_blank":$,rel:x?"noopener noreferrer":v};return c.jsxs(R,{theme:b,ref:k,...C,children:[e,x&&!n&&c.jsxs(V,{size:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),c.jsx("polyline",{points:"15,3 21,3 21,9"}),c.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})]})});g.displayName="Link";exports.Link=g;
//# sourceMappingURL=link.cjs.map