Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: unstyled anchor element #49

Merged
merged 15 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/components/accordion/__styles__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,23 @@ export const ElAccordionContainer = styled.div`
flex-direction: column;
`

export const ElAccordionItem = styled.div`
export const ElAccordionItem = styled.a`
color: inherit;
font-size: inherit;
font-weight: inherit;

&:hover,
&:link,
&:active,
&:focus {
color: inherit;
font-size: inherit;
font-weight: inherit;
}

display: flex;
justify-content: space-between;
align-items: center;
cursor: pointer;
padding: 0.875rem 0;
border-bottom: 1px solid var(--color-grey-100);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports[`Accordion basic usage should match a snapshot 1`] = `
"baseElement": <body>
<div>
<mock-styled.div>
<mock-styled.div>
<mock-styled.a>
<mock-styled.div>
Accordion Item 1
</mock-styled.div>
Expand Down Expand Up @@ -42,13 +42,13 @@ exports[`Accordion basic usage should match a snapshot 1`] = `
</mock-styled.span>
</mock-styled.div>
</mock-styled.div>
</mock-styled.div>
</mock-styled.a>
<mock-styled.div
classname="mock-css."
>
Accordion Content 1
</mock-styled.div>
<mock-styled.div>
<mock-styled.a>
<mock-styled.div>
Accordion Item 2
</mock-styled.div>
Expand Down Expand Up @@ -84,7 +84,7 @@ exports[`Accordion basic usage should match a snapshot 1`] = `
</mock-styled.span>
</mock-styled.div>
</mock-styled.div>
</mock-styled.div>
</mock-styled.a>
<mock-styled.div>
Accordion Content 2
</mock-styled.div>
Expand All @@ -93,7 +93,7 @@ exports[`Accordion basic usage should match a snapshot 1`] = `
</body>,
"container": <div>
<mock-styled.div>
<mock-styled.div>
<mock-styled.a>
<mock-styled.div>
Accordion Item 1
</mock-styled.div>
Expand Down Expand Up @@ -129,13 +129,13 @@ exports[`Accordion basic usage should match a snapshot 1`] = `
</mock-styled.span>
</mock-styled.div>
</mock-styled.div>
</mock-styled.div>
</mock-styled.a>
<mock-styled.div
classname="mock-css."
>
Accordion Content 1
</mock-styled.div>
<mock-styled.div>
<mock-styled.a>
<mock-styled.div>
Accordion Item 2
</mock-styled.div>
Expand Down Expand Up @@ -171,7 +171,7 @@ exports[`Accordion basic usage should match a snapshot 1`] = `
</mock-styled.span>
</mock-styled.div>
</mock-styled.div>
</mock-styled.div>
</mock-styled.a>
<mock-styled.div>
Accordion Content 2
</mock-styled.div>
Expand Down Expand Up @@ -237,7 +237,7 @@ exports[`Accordion react shorthand should match a snapshot 1`] = `
"baseElement": <body>
<div>
<mock-styled.div>
<mock-styled.div
<mock-styled.a
aria-controls=":r0:-0"
id=":r1:-0"
>
Expand Down Expand Up @@ -281,7 +281,7 @@ exports[`Accordion react shorthand should match a snapshot 1`] = `
</mock-styled.span>
</mock-styled.div>
</mock-styled.div>
</mock-styled.div>
</mock-styled.a>
<mock-styled.div
aria-expanded="false"
aria-labelledby=":r1:-0"
Expand All @@ -291,7 +291,7 @@ exports[`Accordion react shorthand should match a snapshot 1`] = `
>
Accordion Content 1
</mock-styled.div>
<mock-styled.div
<mock-styled.a
aria-controls=":r0:-1"
id=":r1:-1"
>
Expand Down Expand Up @@ -335,7 +335,7 @@ exports[`Accordion react shorthand should match a snapshot 1`] = `
</mock-styled.span>
</mock-styled.div>
</mock-styled.div>
</mock-styled.div>
</mock-styled.a>
<mock-styled.div
aria-expanded="false"
aria-labelledby=":r1:-1"
Expand All @@ -350,7 +350,7 @@ exports[`Accordion react shorthand should match a snapshot 1`] = `
</body>,
"container": <div>
<mock-styled.div>
<mock-styled.div
<mock-styled.a
aria-controls=":r0:-0"
id=":r1:-0"
>
Expand Down Expand Up @@ -394,7 +394,7 @@ exports[`Accordion react shorthand should match a snapshot 1`] = `
</mock-styled.span>
</mock-styled.div>
</mock-styled.div>
</mock-styled.div>
</mock-styled.a>
<mock-styled.div
aria-expanded="false"
aria-labelledby=":r1:-0"
Expand All @@ -404,7 +404,7 @@ exports[`Accordion react shorthand should match a snapshot 1`] = `
>
Accordion Content 1
</mock-styled.div>
<mock-styled.div
<mock-styled.a
aria-controls=":r0:-1"
id=":r1:-1"
>
Expand Down Expand Up @@ -448,7 +448,7 @@ exports[`Accordion react shorthand should match a snapshot 1`] = `
</mock-styled.span>
</mock-styled.div>
</mock-styled.div>
</mock-styled.div>
</mock-styled.a>
<mock-styled.div
aria-expanded="false"
aria-labelledby=":r1:-1"
Expand Down
5 changes: 3 additions & 2 deletions src/components/accordion/accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { elIsActive } from '../../styles/states'
import { Icon } from '../icon'

export interface AccordionBaseProps extends HTMLAttributes<HTMLDivElement> {}
export interface AccordionBaseItemProps extends HTMLAttributes<HTMLAnchorElement> {}

export interface AccordionTitleItemProps {}

Expand All @@ -30,11 +31,11 @@ export const AccordionContainer: FC<AccordionBaseProps> = ({ children, ...rest }
return <ElAccordionContainer {...rest}>{children}</ElAccordionContainer>
}

export const AccordionItem: FC<AccordionBaseProps> = ({ children, ...rest }) => {
export const AccordionItem: FC<AccordionBaseItemProps> = ({ children, ...rest }) => {
return <ElAccordionItem {...rest}>{children}</ElAccordionItem>
}

export const AccordionTitle: FC<AccordionBaseProps> = ({ children, ...rest }) => {
export const AccordionTitle: FC<HTMLAttributes<HTMLDivElement>> = ({ children, ...rest }) => {
return <ElAccordionTitle {...rest}>{children}</ElAccordionTitle>
}

Expand Down
3 changes: 2 additions & 1 deletion src/components/breadcrumb/__styles__/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { styled } from '@linaria/react'

export const ElBreadCrumbItem = styled.div`
export const ElBreadCrumbItem = styled.a`
font-weight: inherit;
border-radius: 0.5rem;
font-size: var(--font-size-small);
color: var(--intent-default);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ exports[`BreadCrumb should match a snapshot 1`] = `
align-items: center;
"
>
<mock-styled.div
<mock-styled.a
aria-current="false"
>
Home
</mock-styled.div>
</mock-styled.a>
</mock-styled.div>
<mock-styled.div
classname="mock-css.
Expand All @@ -37,11 +37,11 @@ exports[`BreadCrumb should match a snapshot 1`] = `
style="font-size: 12px;"
/>
</mock-styled.span>
<mock-styled.div
<mock-styled.a
aria-current="false"
>
Level 1
</mock-styled.div>
</mock-styled.a>
</mock-styled.div>
<mock-styled.div
classname="mock-css.
Expand All @@ -61,11 +61,11 @@ exports[`BreadCrumb should match a snapshot 1`] = `
style="font-size: 12px;"
/>
</mock-styled.span>
<mock-styled.div
<mock-styled.a
aria-current="false"
>
Level 2
</mock-styled.div>
</mock-styled.a>
</mock-styled.div>
<mock-styled.div
classname="mock-css.
Expand All @@ -85,11 +85,11 @@ exports[`BreadCrumb should match a snapshot 1`] = `
style="font-size: 12px;"
/>
</mock-styled.span>
<mock-styled.div
<mock-styled.a
aria-current="page"
>
Level 3
</mock-styled.div>
</mock-styled.a>
</mock-styled.div>
</mock-styled.div>
</div>
Expand All @@ -103,11 +103,11 @@ exports[`BreadCrumb should match a snapshot 1`] = `
align-items: center;
"
>
<mock-styled.div
<mock-styled.a
aria-current="false"
>
Home
</mock-styled.div>
</mock-styled.a>
</mock-styled.div>
<mock-styled.div
classname="mock-css.
Expand All @@ -127,11 +127,11 @@ exports[`BreadCrumb should match a snapshot 1`] = `
style="font-size: 12px;"
/>
</mock-styled.span>
<mock-styled.div
<mock-styled.a
aria-current="false"
>
Level 1
</mock-styled.div>
</mock-styled.a>
</mock-styled.div>
<mock-styled.div
classname="mock-css.
Expand All @@ -151,11 +151,11 @@ exports[`BreadCrumb should match a snapshot 1`] = `
style="font-size: 12px;"
/>
</mock-styled.span>
<mock-styled.div
<mock-styled.a
aria-current="false"
>
Level 2
</mock-styled.div>
</mock-styled.a>
</mock-styled.div>
<mock-styled.div
classname="mock-css.
Expand All @@ -175,11 +175,11 @@ exports[`BreadCrumb should match a snapshot 1`] = `
style="font-size: 12px;"
/>
</mock-styled.span>
<mock-styled.div
<mock-styled.a
aria-current="page"
>
Level 3
</mock-styled.div>
</mock-styled.a>
</mock-styled.div>
</mock-styled.div>
</div>,
Expand Down
1 change: 1 addition & 0 deletions src/components/breadcrumb/breadcrumb.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default {
export const BasicUsage = {
render: ({}) => (
<BreadCrumb
defaultActiveIndex={3}
items={[
{
text: 'Home',
Expand Down
6 changes: 3 additions & 3 deletions src/components/breadcrumb/breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import { Icon } from '../icon'
import { elMr2 } from '../../styles/spacing'
import { FlexContainer } from '../layout'

export interface BreadCrumbItem extends HTMLAttributes<HTMLDivElement> {
export interface BreadCrumbItem extends HTMLAttributes<HTMLAnchorElement> {
text: string
onClick: () => void
}

export interface BreadCrumbProps extends HTMLAttributes<HTMLDivElement> {
export interface BreadCrumbProps extends HTMLAttributes<HTMLElement> {
items: BreadCrumbItem[]
defaultActiveIndex?: number
}

export const handleNext =
(setActive: Dispatch<SetStateAction<number>>, onClick: () => void, index: number) =>
(e: MouseEvent<HTMLDivElement>) => {
(e: MouseEvent<HTMLAnchorElement>) => {
e.preventDefault()
setActive(index)
onClick()
Expand Down
Loading
Loading