Skip to content

Commit

Permalink
apply suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
layershifter committed Dec 29, 2023
1 parent c661d20 commit 232c41f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 55 deletions.
21 changes: 9 additions & 12 deletions src/addons/Confirm/Confirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ import Modal from '../../modules/Modal'
* A Confirm modal gives the user a choice to confirm or cancel an action.
* @see Modal
*/
const Confirm = React.forwardRef(function (partialProps, ref) {
const props = _.defaults(partialProps, getDefaultProps())
const { cancelButton, confirmButton, content, header, open, size } = props
const Confirm = React.forwardRef(function (props, ref) {
const {
cancelButton = 'Cancel',
confirmButton = 'OK',
content = 'Are you sure?',
header,
open,
size = 'small',
} = props
const rest = getUnhandledProps(Confirm, props)

const handleCancel = (e) => {
Expand Down Expand Up @@ -97,13 +103,4 @@ Confirm.propTypes = {
size: PropTypes.oneOf(['mini', 'tiny', 'small', 'large', 'fullscreen']),
}

function getDefaultProps() {
return {
cancelButton: 'Cancel',
confirmButton: 'OK',
content: 'Are you sure?',
size: 'small',
}
}

export default Confirm
64 changes: 31 additions & 33 deletions src/addons/Pagination/Pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,30 @@ import PaginationItem from './PaginationItem'
/**
* A component to render a pagination.
*/
const Pagination = React.forwardRef(function (partialProps, ref) {
const props = _.defaults(partialProps, getDefaultProps())
const Pagination = React.forwardRef(function (props, ref) {
const {
'aria-label': ariaLabel,
boundaryRange,
'aria-label': ariaLabel = 'Pagination Navigation',
boundaryRange = 1,
disabled,
ellipsisItem,
siblingRange,
ellipsisItem = '...',
firstItem = {
'aria-label': 'First item',
content: '«',
},
lastItem = {
'aria-label': 'Last item',
content: '»',
},
nextItem = {
'aria-label': 'Next item',
content: '⟩',
},
pageItem = {},
prevItem = {
'aria-label': 'Previous item',
content: '⟨',
},
siblingRange = 1,
totalPages,
} = props
const [activePage, setActivePage] = useAutoControlledValue({
Expand Down Expand Up @@ -64,10 +80,18 @@ const Pagination = React.forwardRef(function (partialProps, ref) {
})
const rest = getUnhandledProps(Pagination, props)

const paginationItemTypes = {
firstItem,
lastItem,
nextItem,
pageItem,
prevItem,
}

return (
<Menu {...rest} aria-label={ariaLabel} pagination role='navigation' ref={ref}>
{_.map(items, ({ active, type, value }) =>
PaginationItem.create(props[type], {
PaginationItem.create(paginationItemTypes[type], {
defaultProps: {
content: value,
disabled,
Expand Down Expand Up @@ -130,32 +154,6 @@ Pagination.propTypes = {
totalPages: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
}

function getDefaultProps() {
return {
'aria-label': 'Pagination Navigation',
boundaryRange: 1,
ellipsisItem: '...',
firstItem: {
'aria-label': 'First item',
content: '«',
},
lastItem: {
'aria-label': 'Last item',
content: '»',
},
nextItem: {
'aria-label': 'Next item',
content: '⟩',
},
pageItem: {},
prevItem: {
'aria-label': 'Previous item',
content: '⟨',
},
siblingRange: 1,
}
}

Pagination.Item = PaginationItem

export default Pagination
12 changes: 2 additions & 10 deletions src/addons/Radio/Radio.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import _ from 'lodash'
import React from 'react'

import { getUnhandledProps } from '../../lib'
Expand All @@ -10,9 +9,8 @@ import Checkbox from '../../modules/Checkbox'
* @see Checkbox
* @see Form
*/
const Radio = React.forwardRef(function (partialProps, ref) {
const props = _.defaults(partialProps, getDefaultProps())
const { slider, toggle, type } = props
const Radio = React.forwardRef(function (props, ref) {
const { slider, toggle, type = 'radio' } = props

const rest = getUnhandledProps(Radio, props)
// const ElementType = getElementType(Radio, props)
Expand All @@ -35,10 +33,4 @@ Radio.propTypes = {
type: Checkbox.propTypes.type,
}

function getDefaultProps() {
return {
type: 'radio',
}
}

export default Radio

0 comments on commit 232c41f

Please sign in to comment.