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

docs: display anchors with icons using Anchor's icon prop #2801

Merged
merged 1 commit into from
Oct 27, 2023
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GithubLogo from 'Docs/contribute/assets/github-logo.js'
import { Icon } from '@dnb/eufemia/src'

You may also be interested in [details about releases](/uilib/releases) and have a look at the [<Icon icon={GithubLogo} size="default" /> **GitHub Releases**](https://github.com/dnbexperience/eufemia/releases) for versioning of the [@dnb/eufemia](/uilib/).
You may also be interested in [details about releases](/uilib/releases) and have a look at the [<Icon icon={GithubLogo} size="default" />**GitHub Releases**](https://github.com/dnbexperience/eufemia/releases) for versioning of the [@dnb/eufemia](/uilib/).
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Icon } from '@dnb/eufemia/src'

# Releases and versions

You may also have a look at the [<Icon icon={GithubLogo} size="default" /> **GitHub Releases**](https://github.com/dnbexperience/eufemia/releases) for versioning of the [@dnb/eufemia](/uilib/).
You may also have a look at the [<Icon icon={GithubLogo} size="default" />**GitHub Releases**](https://github.com/dnbexperience/eufemia/releases) for versioning of the [@dnb/eufemia](/uilib/).

Here you find an overview of all major releases (versions) and changes, including migration guides:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import { Icon } from '@dnb/eufemia/src'

## The Eufemia Repository

The `@dnb/eufemia` is hosted as a sub package inside the [**<Icon icon={EufemiaLogo} size="large" /> Eufemia Repository**](https://github.com/dnbexperience/eufemia) on GitHub.
The `@dnb/eufemia` is hosted as a sub package inside the [<Icon icon={EufemiaLogo} size="large" />**Eufemia Repository**](https://github.com/dnbexperience/eufemia) on GitHub.

You can also enable [<Icon icon={GithubLogo} size="default" /> notification about upcoming releases](https://help.github.com/articles/watching-and-unwatching-releases-for-a-repository/).
You can also enable [<Icon icon={GithubLogo} size="default" />notification about upcoming releases](https://help.github.com/articles/watching-and-unwatching-releases-for-a-repository/).
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Check out the `@dnb/eufemia` **[Installation documentation](/uilib/usage/#instal

## Demo Apps

You find some [Demo Apps](/uilib/getting-started/demos) as well as some setup examples: [<Icon icon={GithubLogo} size="default" /> **eufemia-examples**/packages/...](https://github.com/dnbexperience/eufemia-examples/tree/main/packages)
You find some [Demo Apps](/uilib/getting-started/demos) as well as some setup examples: [<Icon icon={GithubLogo} size="default" />**eufemia-examples**/packages/...](https://github.com/dnbexperience/eufemia-examples/tree/main/packages)

## Be continued

Expand Down
36 changes: 29 additions & 7 deletions packages/dnb-design-system-portal/src/shared/tags/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@
import React from 'react'
import CodeBlock from './CodeBlock'
import { Checkbox, Input } from '@dnb/eufemia/src/components'
import { Ul, Ol, Dl, Li, P, Hr, Blockquote, Code } from '@dnb/eufemia/src'
import {
Ul,
Ol,
Dl,
Li,
P,
Hr,
Blockquote,
Code,
Icon,
} from '@dnb/eufemia/src'
import Table from './Table'
// import Img from './Img'
import Anchor from './Anchor'
Expand Down Expand Up @@ -40,11 +50,21 @@ export const basicComponents = {
</Copy>
)
},
a: Anchor as React.DetailedHTMLFactory<
React.AnchorHTMLAttributes<HTMLAnchorElement>,
HTMLAnchorElement
>,
anchor: Anchor,

a: (props) => {
if (props?.children[0]?.type === Icon) {
// If first children is a Icon, we pass it to Anchor's icon property and sets is position to left
const { children } = props
const [icon, ...restChildren] = children
return (
<Anchor icon={icon} iconPosition="left" {...props}>
{restChildren}
</Anchor>
)
}

return <Anchor {...props} />
},
}

export default {
Expand All @@ -61,7 +81,9 @@ export default {
}
},

link: Anchor,
link: (props) => {
return <Anchor {...props} />
},
input: ({ type, ...rest }) => {
switch (type) {
case 'checkbox':
Expand Down
Loading