Skip to content

Commit

Permalink
few housekeeping changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitskvmdam committed Oct 11, 2021
1 parent 3741e92 commit 965dfc9
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/alert-group/alert-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export const AlertGroup = (props: AlertGroupProps): JSX.Element => {
if (id === ALERT) {
const alert = cloneElement(child, {
...child.props,
portalProps: { isPortalDisabled: true },
portalProps: { hasUseReactPortal: false },
...alertChildProps,
csx: {
...child.csx,
Expand Down
1 change: 0 additions & 1 deletion src/button-group/button-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ const ButtonGroupRoot = createStyledComponent<
const { themeVars, ...themePropsForThemeVarFn } = theme
const { csx = {}, display = 'inline-flex' } = props

console.log('CSX', csx)
return {
boxSizing: 'border-box',
display,
Expand Down
8 changes: 4 additions & 4 deletions src/checkbox/checkbox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,31 @@ const Template: Story = (args) => {
<Checkbox
name="default"
onChange={onChange}
checked={checked.default}
isChecked={checked.default}
{...args}
/>
<Checkbox
name="thumb"
CheckedIcon={<ThumbsChecked />}
UncheckedIcon={<ThumbsUnchecked />}
onChange={onChange}
checked={checked.thumb}
isChecked={checked.thumb}
{...args}
/>
<Checkbox
name="star"
CheckedIcon={<StarChecked />}
UncheckedIcon={<StarUnchecked />}
onChange={onChange}
checked={checked.star}
isChecked={checked.star}
{...args}
/>
<Checkbox
name="heart"
CheckedIcon={<HeartChecked />}
UncheckedIcon={<HeartUnchecked />}
onChange={onChange}
checked={checked.heart}
isChecked={checked.heart}
{...args}
/>
</div>
Expand Down
16 changes: 8 additions & 8 deletions src/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface CheckboxProps
*
* @default false
*/
checked?: boolean
isChecked?: boolean
/**
* Whether checkbox is in indeterminate state
* or not. If true then it will override checked
Expand Down Expand Up @@ -87,7 +87,7 @@ export interface CheckboxProps
* To activate active style
*/
isActive?: boolean

isDisabled?: boolean
classes?: {
/**
* Applied to root component
Expand All @@ -112,7 +112,7 @@ export const Checkbox = (props: CheckboxProps): JSX.Element => {
const {
classes = {},
className,
checked = false,
isChecked = false,
isIndeterminate = false,
CheckedIcon = <DefaultCheckedIcon />,
UncheckedIcon = <DefaultUncheckedIcon />,
Expand All @@ -121,13 +121,13 @@ export const Checkbox = (props: CheckboxProps): JSX.Element => {
innerRef,
inputRef,
id: idProps,
disabled,
isDisabled,
...rest
} = props

const getIconToRender = (): ReactElement => {
if (isIndeterminate) return IndeterminateIcon
if (checked) return CheckedIcon
if (isChecked) return CheckedIcon
return UncheckedIcon
}

Expand All @@ -149,7 +149,7 @@ export const Checkbox = (props: CheckboxProps): JSX.Element => {
} = rest

const iconButtonProps = {
disabled,
isDisabled,
size,
borderStyle,
isDense,
Expand All @@ -170,10 +170,10 @@ export const Checkbox = (props: CheckboxProps): JSX.Element => {
return (
<>
<InputBase
disabled={disabled}
isDisabled={isDisabled}
type={type}
id={id}
checked={isIndeterminate ? false : checked}
checked={isIndeterminate ? false : isChecked}
isHidden={true}
innerRef={inputRef}
{...inputProps}
Expand Down
8 changes: 4 additions & 4 deletions src/form-control-label/form-control-label.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Template: Story = (args) => {
<Checkbox
name="cricket"
onChange={onChange}
checked={checked.cricket}
isChecked={checked.cricket}
/>
}
label="Cricket"
Expand All @@ -43,7 +43,7 @@ const Template: Story = (args) => {
<Checkbox
name="hockey"
onChange={onChange}
checked={checked.hockey}
isChecked={checked.hockey}
/>
}
label="Hockey"
Expand All @@ -54,7 +54,7 @@ const Template: Story = (args) => {
<Checkbox
name="football"
onChange={onChange}
checked={checked.football}
isChecked={checked.football}
/>
}
label="Football"
Expand All @@ -65,7 +65,7 @@ const Template: Story = (args) => {
<Checkbox
name="swimming"
onChange={onChange}
checked={checked.swimming}
isChecked={checked.swimming}
/>
}
label="Swimming"
Expand Down
4 changes: 2 additions & 2 deletions src/inline-alert/inline-alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const InlineAlertRoot = createStyledComponent<typeof Alert, InlineAlertProps>(

return getHoverProperties({
color,
disabled: false,
isDisabled: false,
variant: 'ghost',
theme,
mainColor: color,
Expand Down Expand Up @@ -111,7 +111,7 @@ export const InlineAlert = (props: InlineAlertProps): JSX.Element => {
...getThemeCSSObject(csx.message, theme),
}),
}}
portalProps={{ isPortalDisabled: true }}
portalProps={{ hasUseReactPortal: false }}
{...rest}
/>
</Collapsible>
Expand Down
2 changes: 1 addition & 1 deletion src/inline-alert/inline-alerts.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const Template: Story = (args) => {
<Button
variant="outlined"
color={args.type}
disabled={isOpen}
isDisabled={isOpen}
onClick={() => setIsOpen(true)}
csx={{ root: { margin: '1rem 0' } }}
>
Expand Down
1 change: 1 addition & 0 deletions src/popper/popper.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const Template: Story = (props) => {
},
]}
anchorElement={anchorElement}
isOpen={Boolean(anchorElement)}
{...args}
>
<Box
Expand Down
1 change: 0 additions & 1 deletion src/popper/popper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export const Popper = (props: PopperProp): JSX.Element => {

useLayoutEffect(() => {
let popper: PopperInstance | null = null

if (isValidAnchorElement(anchorElement) && ref.current) {
popper = createPopper(anchorElement, ref.current, {
placement,
Expand Down
8 changes: 4 additions & 4 deletions src/portal/portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ import { PORTAL } from '../constants/component-ids'
export type PortalProps = {
children?: ReactElement
/**
* There are some requirement where a portal element should
* There are some use cases where a portal element should
* behave like none portal element, i.e., it should mount
* according to render tree. For those condition pass false
* here.
*
* @default true
*/
isPortalDisabled?: boolean
hasUseReactPortal?: boolean
}

export const Portal = (props: PortalProps): JSX.Element => {
const { children, isPortalDisabled = false } = props
const { children, hasUseReactPortal = true } = props
const [node] = useState(document.body)

if (isPortalDisabled) return <>{children}</>
if (!hasUseReactPortal) return <>{children}</>

return createPortal(children, node)
}
Expand Down
6 changes: 3 additions & 3 deletions src/radio/radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const CheckboxRoot = createStyledComponent(Checkbox, (theme, props) => {
export const Radio = (props: RadioProps): JSX.Element => {
const context = useRadioGroup()

const { checked, name, value, onChange, ...rest } = props
const { isChecked, name, value, onChange, ...rest } = props

const getCheckedStatus = (): boolean => {
if (typeof checked !== 'undefined') return checked
if (typeof isChecked !== 'undefined') return isChecked
return value === context?.value
}

Expand All @@ -41,7 +41,7 @@ export const Radio = (props: RadioProps): JSX.Element => {
<CheckboxRoot
type="radio"
onChange={handleOnChange}
checked={getCheckedStatus()}
isChecked={getCheckedStatus()}
name={name ?? context?.name}
value={value}
CheckedIcon={<RadioChecked />}
Expand Down
10 changes: 5 additions & 5 deletions src/toggle/toggle.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ const Template: Story = (args) => {
setState(!state)
}

return <Toggle onChange={handleOnChange} checked={state} {...args} />
return <Toggle onChange={handleOnChange} isChecked={state} {...args} />
}

export const Default = Template.bind({})
Default.args = {
disabled: false,
isDisabled: false,
}

const Row = ({ children }) => {
Expand Down Expand Up @@ -64,7 +64,7 @@ const Template2: Story = (args) => {
control={
<Toggle
name="magnifier"
checked={state.magnifier}
isChecked={state.magnifier}
onChange={handleOnChange}
{...args}
/>
Expand All @@ -79,7 +79,7 @@ const Template2: Story = (args) => {
control={
<Toggle
name="narrator"
checked={state.narrator}
isChecked={state.narrator}
onChange={handleOnChange}
{...args}
/>
Expand All @@ -94,7 +94,7 @@ const Template2: Story = (args) => {
control={
<Toggle
name="filter"
checked={state.filter}
isChecked={state.filter}
onChange={handleOnChange}
{...args}
/>
Expand Down
12 changes: 6 additions & 6 deletions src/toggle/toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Checkbox, CheckboxProps } from '../checkbox'
export type ToggleProps = CheckboxProps

export type ToggleIconProps = {
checked: boolean
isChecked: boolean
}

const useStyles = createStyle((theme) => ({
Expand All @@ -30,7 +30,7 @@ const useStyles = createStyle((theme) => ({
theme.palette.common.white,
theme.palette.common.black
),
transform: props.checked ? 'translateX(16px)' : undefined,
transform: props.isChecked ? 'translateX(16px)' : undefined,
}),
}))

Expand Down Expand Up @@ -59,7 +59,7 @@ const CheckboxRoot = createStyledComponent(Checkbox, (theme, props) => {

export const Toggle = (props: ToggleProps): JSX.Element => {
const {
checked = false,
isChecked = false,
size = 'regular',
csx = {},
color = 'primary',
Expand Down Expand Up @@ -91,9 +91,9 @@ export const Toggle = (props: ToggleProps): JSX.Element => {
<CheckboxRoot
type="checkbox"
borderStyle={borderStyle}
color={checked ? color : 'neutral'}
CheckedIcon={<ToggleSVG checked={checked} />}
UncheckedIcon={<ToggleSVG checked={checked} />}
color={isChecked ? color : 'neutral'}
CheckedIcon={<ToggleSVG isChecked={isChecked} />}
UncheckedIcon={<ToggleSVG isChecked={isChecked} />}
csx={{
root: (theme) => ({
...getDimension(),
Expand Down
3 changes: 1 addition & 2 deletions src/tooltip/tooltip.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Story } from '@storybook/react/types-6-0'
import React, { useState } from 'react'

import { Button } from '../button'
import { Box } from '../box'

import { Tooltip } from './tooltip'

export default {
Expand Down
1 change: 0 additions & 1 deletion src/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ export const Tooltip = (props: TooltipProps): JSX.Element => {
)

const [actualPlacement, setActualPlacement] = useState(placement)

const childRefName = isChromatinElement(children)
? 'innerRef'
: _refPropsName
Expand Down

0 comments on commit 965dfc9

Please sign in to comment.