-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add icon prop to LayoutItem (#781)
* feat: add icon prop to LayoutItem
- Loading branch information
1 parent
0521d42
commit 32bf165
Showing
10 changed files
with
152 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
@import '../../../styles/variables.scss'; | ||
@import '../../../styles/mixins.scss'; | ||
|
||
$block: '.#{$ns}icon-wrapper'; | ||
|
||
#{$block} { | ||
$iconSizePositionTop: 32px; | ||
$iconSizePositionLeft: 22px; | ||
|
||
display: flex; | ||
flex-direction: column; | ||
|
||
&_icon-position { | ||
&_left { | ||
flex-direction: row; | ||
} | ||
} | ||
|
||
&__icon { | ||
max-width: 100%; | ||
margin-bottom: $indentXXS; | ||
height: $iconSizePositionTop; | ||
object-fit: contain; | ||
display: block; | ||
|
||
&_icon-position { | ||
&_left { | ||
height: $iconSizePositionLeft; | ||
width: $iconSizePositionLeft; | ||
margin: 1px $indentXXS 1px 0px; | ||
} | ||
} | ||
} | ||
|
||
&_content { | ||
&_left { | ||
@include add-specificity(&) { | ||
flex: 1 0 0; | ||
} | ||
} | ||
} | ||
} |
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,31 @@ | ||
import React, {Fragment, PropsWithChildren} from 'react'; | ||
|
||
import {IconWrapperProps} from '../../models'; | ||
import {block} from '../../utils'; | ||
import Image from '../Image/Image'; | ||
import {getMediaImage} from '../Media/Image/utils'; | ||
|
||
import './IconWrapper.scss'; | ||
|
||
const b = block('icon-wrapper'); | ||
|
||
const IconWrapper = (props: PropsWithChildren<IconWrapperProps>) => { | ||
const {icon, children} = props; | ||
if (!icon) { | ||
return <Fragment>{children}</Fragment>; | ||
} | ||
|
||
const iconProps = getMediaImage(icon.value); | ||
const iconPosition = icon?.position; | ||
|
||
return ( | ||
<div className={b({['icon-position']: iconPosition})}> | ||
{iconProps && ( | ||
<Image {...iconProps} className={b('icon', {['icon-position']: iconPosition})} /> | ||
)} | ||
<div className={b({['content']: iconPosition})}>{children}</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default IconWrapper; |
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
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 |
---|---|---|
|
@@ -20,5 +20,9 @@ $block: '.#{$ns}layout-item'; | |
|
||
&__content { | ||
margin: $indentXS $indentXS 0 0; | ||
|
||
&_no-media { | ||
margin: 0; | ||
} | ||
} | ||
} |
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