Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Fab City OS Suite
fcos-suite-ui
Commits
c68058de
Commit
c68058de
authored
Oct 25, 2022
by
Truong Le
Browse files
fix(icon-component): export and add color prop
parent
392547f2
Pipeline
#3436
passed with stages
in 51 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/components/Icon.tsx
View file @
c68058de
import
React
,
{
Fragment
}
from
"
react
"
;
import
React
,
{
CSSProperties
,
Fragment
}
from
"
react
"
;
import
{
CarbonIconType
}
from
"
@carbon/icons-react
"
;
import
IconModule
from
"
@common/constants
"
;
import
{
Color
}
from
"
@interfaces/INews
"
;
interface
Props
{
name
:
string
;
size
?:
16
|
20
|
24
|
32
|
"
16
"
|
"
20
"
|
"
24
"
|
"
32
"
;
color
?:
Color
;
}
const
Icon
:
React
.
FC
<
Props
>
=
({
name
,
size
=
20
})
=>
{
const
Icon
:
React
.
FC
<
Props
>
=
({
name
,
size
=
20
,
color
})
=>
{
const
Comp
=
(
IconModule
as
Record
<
string
,
CarbonIconType
>
)[
name
]
as
CarbonIconType
;
return
<
Fragment
>
{
Comp
?
<
Comp
size
=
{
size
}
/>
:
null
}
</
Fragment
>;
const
inlineStyle
:
CSSProperties
=
color
?
{
color
}
:
{};
return
(
<
Fragment
>
{
Comp
?
<
Comp
style
=
{
inlineStyle
}
size
=
{
size
}
/>
:
null
}
</
Fragment
>
);
};
export
default
Icon
;
src/index.tsx
View file @
c68058de
...
...
@@ -13,6 +13,7 @@ import Grid from "@components/Grid";
import
HeroBox
from
"
@components/HeroBox
"
;
import
{
HeroSection
}
from
"
@components/HeroSection
"
;
import
{
HorizontalNewsCard
}
from
"
@components/HorizontalNewsCard
"
;
import
Icon
from
"
@components/Icon
"
;
import
{
ImageSlider
}
from
"
@components/ImageSlider
"
;
import
Image
from
"
@components/Image
"
;
import
{
Logo
}
from
"
@components/Logo
"
;
...
...
@@ -44,6 +45,7 @@ export {
HeroBox
,
HeroSection
,
HorizontalNewsCard
,
Icon
,
ImageSlider
,
Image
,
Header
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment