Skip to content

Commit

Permalink
breaking(Popup): rename positioning to position (Semantic-Org#1342)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamdz authored and harel committed Feb 25, 2017
1 parent 204b198 commit b4042a2
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion docs/app/Components/ComponentDoc/ComponentProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class ComponentProps extends Component {

renderRequired = item => item.required && (
<Popup
positioning='right center'
position='right center'
style={{ padding: '0.5em' }}
trigger={<Icon size='small' color='red' name='asterisk' />}
content='Required'
Expand Down
2 changes: 1 addition & 1 deletion docs/app/Components/IconSearch/IconSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default class IconSearch extends Component {
closeOnDocumentClick={false}
style={{ width: '8em', textAlign: 'center' }}
size='mini'
positioning='top center'
position='top center'
content={this.state.copied ? 'Copied!' : 'Click to copy'}
trigger={(
<Grid.Column className='docs-icon-set-column' onClick={this.copy(name)}>
Expand Down
2 changes: 1 addition & 1 deletion docs/app/Examples/modules/Popup/Usage/PopupExampleClick.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const PopupExampleClick = () => (
trigger={<Button color='red' icon='flask' content='Activate doomsday device' />}
content={<Button color='green' content='Confirm the launch' />}
on='click'
positioning='top right'
position='top right'
/>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class PopupExampleControlled extends React.Component {
open={this.state.isOpen}
onClose={this.handleClose}
onOpen={this.handleOpen}
positioning='top right'
position='top right'
/>
</Grid.Column>
<Grid.Column width={8}>
Expand Down
4 changes: 2 additions & 2 deletions docs/app/Examples/modules/Popup/Usage/PopupExampleNested.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const PopupExampleNested = () => (
<Popup
trigger={<Button color='blue' content='Blue Pill' fluid />}
content='The story ends. You wake up in your bed and believe whatever you want to believe.'
positioning='top center'
position='top center'
size='tiny'
inverted
/>
Expand All @@ -17,7 +17,7 @@ const PopupExampleNested = () => (
<Popup
trigger={<Button color='red' content='Red Pill' fluid />}
content='Stay in Wonderland, and I show you how deep the rabbit hole goes.'
positioning='top center'
position='top center'
size='tiny'
inverted
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ const PopupExampleOffset = () => (
trigger={<Icon size='large' name='heart' circular />}
content='Way off to the left'
offset={50}
positioning='left center'
position='left center'
/>
<Popup
trigger={<Icon size='large' name='heart' circular />}
content='As expected this popup is way off to the right'
offset={50}
positioning='right center'
position='right center'
/>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ const PopupExamplePosition = () => (
<Popup
trigger={<Icon name='heart' color='red' size='large' circular />}
content='I am positioned to the top left'
positioning='top left'
position='top left'
/>
</Grid.Column>
<Grid.Column textAlign='center'>
<Popup
trigger={<Icon name='heart' color='red' size='large' circular />}
content='I am positioned to the top center'
positioning='top center'
position='top center'
/>
</Grid.Column>
<Grid.Column textAlign='right'>
<Popup
trigger={<Icon name='heart' color='red' size='large' circular />}
content='I am positioned to the top right'
positioning='top right'
position='top right'
/>
</Grid.Column>
</Grid.Row>
Expand All @@ -31,14 +31,14 @@ const PopupExamplePosition = () => (
<Popup
trigger={<Icon name='heart' color='red' size='large' circular />}
content='I am positioned to the left center'
positioning='left center'
position='left center'
/>
</Grid.Column>
<Grid.Column floated='right' textAlign='right'>
<Popup
trigger={<Icon name='heart' color='red' size='large' circular />}
content='I am positioned to the right center'
positioning='right center'
position='right center'
/>
</Grid.Column>
</Grid.Row>
Expand All @@ -47,21 +47,21 @@ const PopupExamplePosition = () => (
<Popup
trigger={<Icon name='heart' color='red' size='large' circular />}
content='I am positioned to the bottom left'
positioning='bottom left'
position='bottom left'
/>
</Grid.Column>
<Grid.Column textAlign='center'>
<Popup
trigger={<Icon name='heart' color='red' size='large' circular />}
content='I am positioned to the bottom center'
positioning='bottom center'
position='bottom center'
/>
</Grid.Column>
<Grid.Column textAlign='right'>
<Popup
trigger={<Icon name='heart' color='red' size='large' circular />}
content='I am positioned to the bottom right'
positioning='bottom right'
position='bottom right'
/>
</Grid.Column>
</Grid.Row>
Expand Down
20 changes: 10 additions & 10 deletions src/modules/Popup/Popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ export default class Popup extends Component {
*/
onUnmount: PropTypes.func,

/** Positioning for the popover. */
positioning: PropTypes.oneOf(POSITIONS),
/** Position for the popover. */
position: PropTypes.oneOf(POSITIONS),

/** Popup size. */
size: PropTypes.oneOf(_.without(SUI.SIZES, 'medium', 'big', 'massive')),
Expand All @@ -124,7 +124,7 @@ export default class Popup extends Component {
}

static defaultProps = {
positioning: 'top left',
position: 'top left',
on: 'hover',
}

Expand Down Expand Up @@ -223,20 +223,20 @@ export default class Popup extends Component {

setPopupStyle() {
if (!this.coords || !this.popupCoords) return
let positioning = this.props.positioning
let style = this.computePopupStyle(positioning)
let position = this.props.position
let style = this.computePopupStyle(position)

// Lets detect if the popup is out of the viewport and adjust
// the position accordingly
const positions = _.without(POSITIONS, positioning)
const positions = _.without(POSITIONS, position)
for (let i = 0; !this.isStyleInViewport(style) && i < positions.length; i++) {
style = this.computePopupStyle(positions[i])
positioning = positions[i]
position = positions[i]
}

// Append 'px' to every numerical values in the style
style = _.mapValues(style, value => _.isNumber(value) ? value + 'px' : value)
this.setState({ style, positioning })
this.setState({ style, position })
}

getPortalProps() {
Expand Down Expand Up @@ -323,11 +323,11 @@ export default class Popup extends Component {
wide,
} = this.props

const { positioning, closed } = this.state
const { position, closed } = this.state
const style = _.assign({}, this.state.style, this.props.style)
const classes = cx(
'ui',
positioning,
position,
size,
useKeyOrValueAndKey(wide, 'wide'),
useKeyOnly(basic, 'basic'),
Expand Down
4 changes: 2 additions & 2 deletions src/modules/Popup/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ interface PopupProps extends PortalProps {
/** Event triggering the popup. */
on?: 'hover' | 'click' | 'focus';

/** Positioning for the popover. */
positioning?: 'top left' | 'top right' |
/** Position for the popover. */
position?: 'top left' | 'top right' |
'bottom right' | 'bottom left' |
'right center' | 'left center' |
'top center' | 'bottom center';
Expand Down
8 changes: 4 additions & 4 deletions test/specs/modules/Popup/Popup-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('Popup', () => {
wrapperMount(
<Popup
offset={50}
positioning='bottom right'
position='bottom right'
content='foo'
trigger={<button>foo</button>}
/>
Expand All @@ -95,7 +95,7 @@ describe('Popup', () => {
wrapperMount(
<Popup
offset={50}
positioning='bottom left'
position='bottom left'
content='foo'
trigger={<button>foo</button>}
/>
Expand All @@ -106,13 +106,13 @@ describe('Popup', () => {
})
})

describe('positioning', () => {
describe('position', () => {
POSITIONS.forEach(position => {
it('is always within the viewport', () => {
wrapperMount(
<Popup
content='_'
positioning={position}
position={position}
trigger={<button>foo</button>}
on='click'
/>
Expand Down

0 comments on commit b4042a2

Please sign in to comment.