-
Notifications
You must be signed in to change notification settings - Fork 45
refactor(*): replace style props with CSS classNames - #320 #387
base: master
Are you sure you want to change the base?
refactor(*): replace style props with CSS classNames - #320 #387
Conversation
@arteevraina. Tagging you here so you can get notified when this PR gets merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments and questions.
src/ErrorLogger/Error.js
Outdated
}; | ||
|
||
const shortMessageProps = { | ||
onClick: handleClickSpecError, | ||
shortMessage: errorProps.ERROR_SHORT_MESSAGE, | ||
}; | ||
|
||
const fullMessageProps = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fullMessageProps
isn't needed anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the feedback
src/ErrorLogger/Error.js
Outdated
}; | ||
|
||
return ( | ||
<SC.ErrorComponent {...componentProps}> | ||
<SC.ErrorComponent className={'errorComponent'}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do all these need to be className="..."
instead of className={'...'}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, they need to be className="..."
. I'll change them!
src/ErrorLogger/customStyles.js
Outdated
import styled from 'styled-components'; | ||
|
||
export const CustomStylesWrapper = styled.div` | ||
.errorHeader{ | ||
}; | ||
.errorDisplay{ | ||
}; | ||
.errorBarArrow{ | ||
}; | ||
.errorComponent{ | ||
}; | ||
.errorFile{ | ||
}; | ||
.errorArrowDivExpanded{ | ||
}; | ||
.errorArrowDivCollapsed{ | ||
}; | ||
.errorType{ | ||
}; | ||
.errorShortMessage{ | ||
}; | ||
.errorFullMessage{ | ||
}; | ||
` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain more why these custom style wrappers help / what they do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I first added them they meant sense to me as it is one of the best way for me to added custom CSS style to elements. But now it doesn't seem required at all since the user will be adding his/her own wrapper around the component or style document. Sorry for the inconvenience, I'll be removing it!
src/ErrorLogger/styles.js
Outdated
z-index: ${props => props.zIndexInput || 'auto'}; | ||
background-color: #1E2D53; | ||
box-shadow: 0 -2px 20px 0 rgba(20,31,60,0.65); | ||
z-index: auto; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto
is the default value for z-index
, so these can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the feedback
src/Navigation/styles.js
Outdated
width: ${props => props.navWidth || 'inherit'}; | ||
background-color: ${props => props.backgroundColor || 'inherit'}; | ||
position: static; | ||
top: auto; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto
is the default value for top
, so this can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the feedback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also give the highest parent of each component a common class name? maybe ciceroUI
? That way we can easily target specific elements within the ciceroUI parent.
I'd also like an explanation of the CustomStylesWrapper
that you've added for each component. Thanks!
@DianaLease When I first added them they meant sense to me as it is one of the best way for me to added custom CSS style to elements. But now it doesn't seem required at all since the user will be adding his/her own wrapper around the component or style document. Sorry for the inconvenience, I'll be removing it! |
69ad521
to
2c9fd4e
Compare
|
||
return ( | ||
<TemplatesWrapper> | ||
<TemplatesWrapper className='ciceroUI'> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this class name be more specific?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping @DianaLease comment in mind, do I need to add specific class names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @DianaLease is correct, so this could be left.
@irmerk I think it makes sense to have a common className at the top level for all cicero-ui components. Like how semantic-ui adds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made some different suggestions to keep the className
more consistent.
src/TemplateLibrary/index.js
Outdated
{props.addTemp | ||
&& <NewClauseComponent addTempInput={props.addTemp} />} | ||
</Functionality> | ||
<TemplateCards tempsHeight={libraryProps.TEMPLATES_HEIGHT} > | ||
<TemplateCards className='templateCardsDiv' > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this could be 'templateLibraryCardsWrapper'
|
||
return ( | ||
<TemplatesWrapper> | ||
<TemplatesWrapper className='ciceroUI'> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @DianaLease is correct, so this could be left.
src/Navigation/ComponentSwitch.js
Outdated
NAVIGATION | ||
</SC.Navigation> | ||
<SC.Files {...fileProps}> | ||
<SC.Files {...fileProps} className={props.navState === 'FILES'?'navTitleActive':'navTitleInactive'}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this could be 'navigationFilesActive'
and 'navigationFilesInactive'
Following up on this @98lenvi, need any assistance? |
@irmerk, actually my laptop's hard drive died a week ago. I'm waiting for the new drive to arrive (most probably tonight or tomorrow morning). I'll do the changes tomorrow morning! |
… - i320 Signed-off-by: Lenvin Gonsalves <lenvin@oykuapp.com>
…- i320 Signed-off-by: Lenvin Gonsalves <lenvin@oykuapp.com>
…ames - i320 Signed-off-by: Lenvin Gonsalves <lenvin@oykuapp.com>
Signed-off-by: Lenvin Gonsalves <lenvin@oykuapp.com>
Signed-off-by: Lenvin Gonsalves <lenvin@oykuapp.com>
Signed-off-by: Lenvin Gonsalves <lenvin@oykuapp.com>
Signed-off-by: Lenvin Gonsalves <lenvin@oykuapp.com>
Signed-off-by: Lenvin Gonsalves <lenvin@oykuapp.com>
42a5597
to
3b7c7ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more remaining changes.
{props.addTemp | ||
&& <NewClauseComponent addTempInput={props.addTemp} />} | ||
</Functionality> | ||
{filtered && filtered.length ? <TemplateCards tempsHeight={libraryProps.TEMPLATES_HEIGHT} > | ||
{filtered && filtered.length ? <TemplateCards className={'templateCardsDiv'} > | ||
{_.sortBy(filtered, ['name']).map(t => ( | ||
<TemplateCard | ||
key={t.uri} | ||
addToCont={props.addToCont} | ||
template={t} | ||
handleViewTemplate={props.handleViewTemplate} | ||
className="templateCard" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this className="templateCard"
can be removed, it's redundant on the className='templateLibraryCard'
in src/TemplateLibrary/Components/TemplateCard.js
<SC.ArrowDiv {...errorArrowProps} /> | ||
<SC.ErrorFile {...fileProps} onClick={() => errorNav(error)} > | ||
<SC.ArrowDiv {...errorArrowProps} className={specErrorVisible?'errorLoggerErrorArrowExpanded':'errorLoggerErrorArrowCollapsed'}/> | ||
<SC.ErrorFile onClick={() => errorNav(error)} className='errorLoggerError'> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'errorLoggerErrorFile'
NAVIGATION | ||
</SC.Navigation> | ||
<SC.Files {...fileProps}> | ||
<SC.Files {...fileProps} className={props.navState === 'FILES'?'navigationTitleActive':'navigationTitleInactive'}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'navigationFilesActive'
and 'navigationFilesInactive'
Also note the proposed changes in #411 |
We're migrating this repository into |
Signed-off-by: Lenvin Gonsalves lenvin@oykuapp.com
Issue #320
The goal is to remove all style props in favor of CSS class names.
One pro I can think of is the user will have more flexibility on the appearance of the component,
Changes
The following will be done for each component
props
for styling in thestyled-components
.props
down.propTypes
as well.customStyles.js
which will have the classNames of the components.styled-component div
which will wrap around the main component.Will be done for the following components
ErrorLogger
ContractEditor (already done during slate migration to 0.57)
Navigation
TemplateLibrary
Flags
Related Issues