-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from Infosys/injiweb-511-homepage-rebranding
[INJIWEB-511]: Add Gradient to Icon
- Loading branch information
Showing
7 changed files
with
31 additions
and
18 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -1,26 +1,29 @@ | ||
import React from "react"; | ||
import { generateRandomString } from "../../utils/misc"; | ||
|
||
export const GradientWrapper:React.FC<BackGroundImageProps> = ({children}) => { | ||
|
||
export const GradientWrapper: React.FC<BackGroundImageProps> = ({children}) => { | ||
const uniqueId = `blue-gradient-${ | ||
generateRandomString(7,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') | ||
}`; | ||
const childrenWithProps = React.Children.map(children, (child) => { | ||
if (React.isValidElement(child)) { | ||
// @ts-ignore | ||
return React.cloneElement(child, {style: { fill: 'url(#blue-gradient)'}}); | ||
return React.cloneElement(child, {style: { fill: `url(#${uniqueId})`,}}); | ||
} | ||
return child; | ||
}); | ||
|
||
return <React.Fragment> | ||
<svg width="0" height="0"> | ||
<linearGradient id="blue-gradient" x1="0%" y1="0%" x2="100%" y2="100%"> | ||
<stop stopColor="var(--iw-color-primary)" offset="0%" /> | ||
<stop stopColor="var(--iw-color-secondary)" offset="100%" /> | ||
</linearGradient> | ||
<linearGradient id={uniqueId} x1="0%" y1="0%" x2="100%" y2="100%"> | ||
<stop stopColor="var(--iw-color-primary)" offset="0%" /> | ||
<stop stopColor="var(--iw-color-secondary)" offset="100%" /> | ||
</linearGradient> | ||
</svg> | ||
{childrenWithProps} | ||
</React.Fragment> | ||
} | ||
}; | ||
|
||
export type BackGroundImageProps = { | ||
children: React.ReactNode; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,4 +98,4 @@ | |
background-position: top; | ||
opacity: 1; | ||
} | ||
} | ||
} |
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