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

Icons to ts #2013

Merged
merged 1 commit into from
May 17, 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
9 changes: 4 additions & 5 deletions packages/ffe-icons-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
"url": "ssh://[email protected]:SpareBank1/designsystem.git"
},
"scripts": {
"build": "ffe-buildtool babel",
"build": "ffe-buildtool tsc",
"clean": "rimraf gen-src lib es types",
"lint": "eslint src",
"lint:fix": "eslint src --fix",
"lint": "eslint src --ext ts,tsx",
"lint:fix": "eslint src --fix --ext ts,tsx",
"test": "ffe-buildtool jest"
},
"dependencies": {
"@sb1/ffe-icons": "^14.0.1",
"prop-types": "^15.7.2"
"@sb1/ffe-icons": "^14.0.1"
},
"devDependencies": {
"@sb1/ffe-buildtool": "^0.6.1",
Expand Down
34 changes: 0 additions & 34 deletions packages/ffe-icons-react/src/Icon.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import Icon from './Icon';
import { Icon } from './Icon';
import { render, screen } from '@testing-library/react';

describe('Icon', () => {
Expand Down
35 changes: 35 additions & 0 deletions packages/ffe-icons-react/src/Icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import classNames from 'classnames';

export interface IconProps extends React.ComponentPropsWithoutRef<'span'> {
/** The path to the svg-file og base64 string */
fileUrl: string;
/** Size of the icon, default is the closest defined font-size */
size?: 'sm' | 'md' | 'lg' | 'xl';
/** Symbols stroke weight. This can affect overall size of symbol, 400 is default */
weight?: 300 | 500;
/** Aria label text. If null/undefined, aria-hidden is automatically set to true */
ariaLabel?: React.ComponentProps<'span'>['aria-label'];
}

export const Icon: React.FC<IconProps> = ({
fileUrl,
className,
ariaLabel,
size = 'md',
...rest
}) => {
return (
<span
role="img"
aria-label={ariaLabel}
aria-hidden={!ariaLabel}
className={classNames('ffe-icons', `ffe-icons--${size}`, className)}
style={{
maskImage: `url(${fileUrl})`,
WebkitMaskImage: `url(${fileUrl})`,
}}
{...rest}
/>
);
};
12 changes: 0 additions & 12 deletions packages/ffe-icons-react/src/index.d.ts

This file was deleted.

3 changes: 0 additions & 3 deletions packages/ffe-icons-react/src/index.js

This file was deleted.

1 change: 1 addition & 0 deletions packages/ffe-icons-react/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Icon, IconProps } from './Icon';
9 changes: 9 additions & 0 deletions packages/ffe-icons-react/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./lib",
"module": "commonjs"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "src/**/*.spec.ts*"]
}
9 changes: 9 additions & 0 deletions packages/ffe-icons-react/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./es",
"module": "esnext"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "src/**/*.spec.ts*"]
}
10 changes: 10 additions & 0 deletions packages/ffe-icons-react/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./types",
"declaration": true,
"emitDeclarationOnly": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "src/**/*.spec.ts*"]
}
Loading