-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Header Component updated to v1 API #278
Changes from 1 commit
9f249cf
4fdc34d
4317290
bdb958d
d10fcda
a69c39e
100525c
6a6d87a
ad81023
6330ca0
e5d4be8
2508c5f
2efe6ec
7ea6275
20bf1ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,16 +13,13 @@ import { | |
function _Header(props) { | ||
const { | ||
_sdClass, _headerElement, | ||
left, center, right, justified, dividing, block, attached, floating, | ||
aligned, dividing, block, attached, floating, | ||
icon, image, children, className, | ||
} = props | ||
|
||
const classes = cx( | ||
_sdClass, 'ui', | ||
useKeyOnly(left, 'left aligned'), | ||
useKeyOnly(center, 'center aligned'), | ||
useKeyOnly(right, 'right aligned'), | ||
useKeyOnly(justified, 'justified'), | ||
aligned === 'justified' ? 'justified' : useValueAndKey(aligned, 'aligned'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update to the latest master and replace this with: -aligned === 'justified' ? 'justified' : useValueAndKey(aligned, 'aligned'),
+useAlignedProp(aligned) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. now using |
||
useKeyOnly(dividing, 'dividing'), | ||
useKeyOnly(block, 'block'), | ||
useKeyOrValueAndKey(attached, 'attached'), | ||
|
@@ -47,6 +44,9 @@ _Header._meta = { | |
library: META.library.semanticUI, | ||
name: '_Header', | ||
type: META.type.element, | ||
props: { | ||
aligned: ['left', 'center', 'right', 'justified'], | ||
}, | ||
} | ||
|
||
_Header.propTypes = { | ||
|
@@ -67,17 +67,8 @@ _Header.propTypes = { | |
PropTypes.element, | ||
]), | ||
|
||
/** Align header content to left */ | ||
left: PropTypes.bool, | ||
|
||
/** Align header content to center */ | ||
center: PropTypes.bool, | ||
|
||
/** Align header content to right */ | ||
right: PropTypes.bool, | ||
|
||
/** Justify content to available space */ | ||
justified: PropTypes.bool, | ||
/** Align header content */ | ||
aligned: PropTypes.oneOf(_Header._meta.props.aligned), | ||
|
||
/** Divide header from the content below it */ | ||
dividing: PropTypes.bool, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import React from 'react' | ||
|
||
import _Header from 'src/elements/Header/_Header' | ||
import * as common from 'test/specs/commonTests' | ||
|
||
describe('_Header', () => { | ||
common.propKeyOnlyToClassName(_Header, 'left', { className: 'aligned' }) | ||
common.propKeyOnlyToClassName(_Header, 'center', { className: 'aligned' }) | ||
common.propKeyOnlyToClassName(_Header, 'right', { className: 'aligned' }) | ||
common.propKeyOnlyToClassName(_Header, 'justified') | ||
common.propKeyAndValueToClassName(_Header, 'aligned') | ||
common.propKeyOnlyToClassName(_Header, 'dividing') | ||
common.propKeyOnlyToClassName(_Header, 'block') | ||
common.propKeyOnlyToClassName(_Header, 'attached') | ||
common.propKeyOnlyToClassName(_Header, 'floating') | ||
|
||
it('does not have aligned class when justified', () => { | ||
shallow(<_Header aligned='justified' />) | ||
.should.not.have.className('aligned') | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once updated and the new prop util and common test are used, you can delete this test: -
- it('does not have aligned class when justified', () => {
- shallow(<_Header aligned='justified' />)
- .should.not.have.className('aligned')
- }) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
}) |
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.
Let's add support for
disabled
andcolor
: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 it's becoming apparent, my inferior knowledge of the Semantic
prop types needs a bit of work. It might aid the process, putting
together a doc of definitive prop types for all components. This might
also help to visualise how these can be simplified across all components
and might help make the api as user friendly as possible?
I'd be happy to undertake this, as would help my knowledge if helping
migrate these components?
Sent from Postbox
https://www.postbox-inc.com/?utm_source=email&utm_medium=siglink&utm_campaign=reach
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.
That is a great idea and it's been on my list. Thanks for trudging through this in it's absence.
I have started some notes in the actual code along side the prop utils themselves here:
https://github.com/TechnologyAdvice/stardust/blob/master/src/utils/propUtils.js#L76
In my head I see a simple markdown file that explains to folks "How to write a component". One of the first orders of business in that doc is the explanation of the component API and the 4 different prop to className permutations (noted in the code linked above).
I think even starting a markdown file with just that ^ information in it for now is a good start. We can iterate and add as we go. I'll keep this on my list, but if you get to it before me I'll gladly review and contribute.
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.
Issue created: https://github.com/TechnologyAdvice/stardust/issues/282