-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Icon): rewrite to TypeScript and hooks (#3703)
Will solve the issue described in this PR #3699 Even all the tests and types are running green, it needs extensive manual testing. --------- Co-authored-by: Anders <anderslangseth@gmail.com>
- Loading branch information
1 parent
5a2d95f
commit 70b1f8b
Showing
16 changed files
with
560 additions
and
624 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
packages/dnb-eufemia/src/components/icon-primary/IconPrimary.d.ts
This file was deleted.
Oops, something went wrong.
75 changes: 0 additions & 75 deletions
75
packages/dnb-eufemia/src/components/icon-primary/IconPrimary.js
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
packages/dnb-eufemia/src/components/icon-primary/IconPrimary.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React, { useContext } from 'react' | ||
import Context from '../../shared/Context' | ||
import { extendPropsWithContext } from '../../shared/component-helper' | ||
import { | ||
prerenderIcon, | ||
prepareIcon, | ||
IconAllProps, | ||
IconProps, | ||
} from '../icon/Icon' | ||
|
||
// NB: The path reflects the rollup.config.js -> external: '../../icons/dnb/primary_icons' | ||
import * as primary_icons from '../../icons/dnb/primary_icons' | ||
import * as primary_icons_medium from '../../icons/dnb/primary_icons_medium' | ||
|
||
export * from '../icon/Icon' | ||
|
||
export type IconPrimaryProps = IconProps | ||
export type IconPrimaryAllProps = IconAllProps | ||
|
||
const icons = { ...primary_icons, ...primary_icons_medium } | ||
|
||
export default function IconPrimary(localProps: IconAllProps) { | ||
const context = useContext(Context) | ||
|
||
// use only the props from context, who are available here anyway | ||
const props = extendPropsWithContext( | ||
localProps, | ||
{}, | ||
{ skeleton: context?.skeleton }, | ||
context.Icon, | ||
context.IconPrimary | ||
) | ||
|
||
const { icon, size, wrapperParams, iconParams, alt } = prepareIcon( | ||
props, | ||
context | ||
) | ||
|
||
const IconContainer = prerenderIcon({ | ||
icon, | ||
size, | ||
alt, | ||
listOfIcons: icons, | ||
}) | ||
|
||
if (!IconContainer) { | ||
return <></> | ||
} | ||
|
||
return ( | ||
<span {...wrapperParams}> | ||
<IconContainer {...iconParams} /> | ||
</span> | ||
) | ||
} | ||
|
||
IconPrimary._supportsSpacingProps = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.