Skip to content

Commit

Permalink
Buttons inside Forms
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejoYarce committed Jan 16, 2025
1 parent 431ed5e commit 086638d
Show file tree
Hide file tree
Showing 27 changed files with 102 additions and 28 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ function App() {

### Buttons

- [Button](https://github.com/wri/wri-design-systems/tree/main/src/components/Buttons/Button)
- [Icon Button](https://github.com/wri/wri-design-systems/tree/main/src/components/Buttons/IconButton)
- [Close Button](https://github.com/wri/wri-design-systems/tree/main/src/components/Buttons/CloseButton)
- [Button](https://github.com/wri/wri-design-systems/tree/main/src/components/Forms/Buttons/Button)
- [Icon Button](https://github.com/wri/wri-design-systems/tree/main/src/components/Forms/Buttons/IconButton)
- [Close Button](https://github.com/wri/wri-design-systems/tree/main/src/components/Forms/Buttons/CloseButton)

### Controls

Expand Down
6 changes: 3 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-vars */

import SwitchDemo from './components/Switch/SwitchDemo'
import ButtonDemo from './components/Buttons/Button/ButtonDemo'
import ButtonDemo from './components/Forms/Buttons/Button/ButtonDemo'
import RadioDemo from './components/Radio/RadioDemo'
import TabBarDemo from './components/TabBar/TabBarDemo'
import CheckboxDemo from './components/Checkbox/CheckboxDemo'
Expand All @@ -10,8 +10,8 @@ import TagDemo from './components/Tag/TagDemo'
import InlineMessageDemo from './components/InlineMessage/InlineMessageDemo'
import TextInputDemo from './components/TextInput/TextInputDemo'
import TextareaDemo from './components/Textarea/TextareaDemo'
import CloseButtonDemo from './components/Buttons/CloseButton/CloseButtonDemo'
import IconButtonDemo from './components/Buttons/IconButton/IconButtonDemo'
import CloseButtonDemo from './components/Forms/Buttons/CloseButton/CloseButtonDemo'
import IconButtonDemo from './components/Forms/Buttons/IconButton/IconButtonDemo'
import SliderDemo from './components/Slider/SliderDemo'
import QualitativeDemo from './components/Legend/QualitativeLegend/QualitativeLegendDemo'
import LayerParametersDemo from './components/Legend/LayerParameters/LayerParametersDemo'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react'
import type { Meta, StoryObj } from '@storybook/react'
import { fn } from '@storybook/test'
import Button from '.'
import { CheckIcon } from '../../icons'
import { CheckIcon } from '../../../icons'

const meta = {
title: 'Forms/Buttons/Button',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button } from '../..'
import { Button } from '../../..'

const ButtonDemo = () => (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[Storybook Ref](https://wri.github.io/wri-design-systems/?path=/docs/forms-buttons-button--docs)

[ButtonDemo](https://github.com/wri/wri-design-systems/blob/main/src/components/Buttons/Button/ButtonDemo.tsx)
[ButtonDemo](https://github.com/wri/wri-design-systems/blob/main/src/components/Forms/Buttons/Button/ButtonDemo.tsx)

## Import

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from '@emotion/styled'
import { Button } from '@chakra-ui/react'
import { getThemedColor } from '../../../lib/theme'
import { getThemedColor } from '../../../../lib/theme'
import { ButtonProps } from './types'

export const BaseButton = styled(Button)<ButtonProps>`
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CloseButton } from '../..'
import { CloseButton } from '../../..'

const CloseButtonDemo = () => (
<div style={{ display: 'flex', flexDirection: 'column', gap: '10px' }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[Storybook Ref](https://wri.github.io/wri-design-systems/?path=/docs/forms-buttons-close-button--docs)

[CloseButtonDemo](https://github.com/wri/wri-design-systems/blob/main/src/components/Buttons/CloseButton/CloseButtonDemo.tsx)
[CloseButtonDemo](https://github.com/wri/wri-design-systems/blob/main/src/components/Forms/Buttons/CloseButton/CloseButtonDemo.tsx)

## Import

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'

import { StyledCloseButton } from './styled'
import { CloseButtonProps } from './types'
import { CloseIcon } from '../../icons'
import { CloseIcon } from '../../../icons'

const CloseButton = ({ disabled, ...rest }: CloseButtonProps) => (
<StyledCloseButton
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from '@emotion/styled'
import { getThemedColor } from '../../../lib/theme'
import { getThemedColor } from '../../../../lib/theme'
import IconButton from '../IconButton'

export const StyledCloseButton = styled(IconButton)`
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react'
import type { Meta, StoryObj } from '@storybook/react'
import { fn } from '@storybook/test'
import IconButton from '.'
import { ChevronDownIcon, MenuDotsIcon } from '../../icons'
import { ChevronDownIcon, MenuDotsIcon } from '../../../icons'

const meta = {
title: 'Forms/Buttons/Icon Button',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IconButton } from '../..'
import { CheckIcon, InfoIcon, MenuDotsIcon } from '../../icons'
import { IconButton } from '../../..'
import { CheckIcon, InfoIcon, MenuDotsIcon } from '../../../icons'

const IconButtonDemo = () => (
<div style={{ display: 'flex', flexDirection: 'column', gap: '10px' }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[Storybook Ref](https://wri.github.io/wri-design-systems/?path=/docs/forms-buttons-icon-button--docs)

[IconButtonDemo](https://github.com/wri/wri-design-systems/blob/main/src/components/Buttons/IconButton/IconButtonDemo.tsx)
[IconButtonDemo](https://github.com/wri/wri-design-systems/blob/main/src/components/Forms/Buttons/IconButton/IconButtonDemo.tsx)

## Import

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from '@emotion/styled'
import { Button } from '@chakra-ui/react'
import { getThemedColor } from '../../../lib/theme'
import { getThemedColor } from '../../../../lib/theme'

export const StyledIconButton = styled(Button)`
width: 20px !important;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/components/InlineMessage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import React from 'react'

import Button from '../Buttons/Button'
import Button from '../Forms/Buttons/Button'
import { InfoIcon } from '../icons'
import {
InfoWhiteInlineMessage,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Layer/LayerItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React from 'react'

import { Box } from '@chakra-ui/react'
import Button from '../../Buttons/Button'
import Button from '../../Forms/Buttons/Button'
import Switch from '../../Switch'
import Radio from '../../Radio'
import { LayerItemProps } from './types'
Expand Down
4 changes: 2 additions & 2 deletions src/components/Legend/LegendItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
LegendItemLayerName,
LegendItemButtonsContainer,
} from './styled'
import Button from '../../Buttons/Button'
import Button from '../../Forms/Buttons/Button'
import { ChevronDownIcon, CloseIcon, DotsIcon, InfoIcon } from '../../icons'
import IconButton from '../../Buttons/IconButton'
import IconButton from '../../Forms/Buttons/IconButton'
import OpacityControl from '../OpacityControl'

const LegendItem = ({
Expand Down
74 changes: 74 additions & 0 deletions src/components/Legend/LegendPanel/DraggableItem.tsxaaa
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import React from 'react'

import { useSortable } from '@dnd-kit/sortable'
import { CSS } from '@dnd-kit/utilities'
import { DraggableItemProps } from './types'

type Props = {
item: DraggableItemProps
removeItem: (id: number) => void
forceDragging?: boolean
}

const DraggableItem = ({
// eslint-disable-next-line @typescript-eslint/no-unused-vars
item,
removeItem,
forceDragging = false,
}: Props) => {
const {
attributes,
isDragging,
listeners,
setNodeRef,
setActivatorNodeRef,
transform,
transition,
} = useSortable({
id: item.sequence,
})

const parentStyles = {
transform: CSS.Transform.toString(transform),
transition: transition || undefined,
opacity: isDragging ? '0.4' : '1',
lineHeight: '4',
}

const draggableStyles = {
cursor: isDragging || forceDragging ? 'grabbing' : 'grab',
}

return (
<div style={parentStyles} ref={setNodeRef}>
<div
ref={setActivatorNodeRef}
className='flex-grow p-2'
style={draggableStyles}
{...attributes}
{...listeners}
>
{item.child}
</div>

<p>{item.sequence}</p>

<div
ref={setActivatorNodeRef}
className='flex-grow p-2'
style={draggableStyles}
{...attributes}
{...listeners}
>
<p>{item.id}</p>
</div>

<button type='button' onClick={() => removeItem(item.id)}>
X
</button>
</div>
)
}

export default DraggableItem
2 changes: 1 addition & 1 deletion src/components/Legend/OpacityControl/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React, { useState } from 'react'

import { Popover as ChakraPopover } from '@chakra-ui/react'
import Button from '../../Buttons/Button'
import Button from '../../Forms/Buttons/Button'
import { InfoIcon } from '../../icons'
import TextInput from '../../TextInput'
import Slider from '../../Slider'
Expand Down
2 changes: 1 addition & 1 deletion src/components/Legend/QualitativeLegend/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
RasterIndicator,
} from './styled'
import { HideIcon, ShowIcon } from '../../icons'
import Button from '../../Buttons/Button'
import Button from '../../Forms/Buttons/Button'

const QualitativeLegend = ({
type,
Expand Down
6 changes: 3 additions & 3 deletions src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { default as Switch } from './Switch'
export { default as Button } from './Buttons/Button'
export { default as Button } from './Forms/Buttons/Button'
export { default as NavigationRail } from './NavigationRail'
export { default as Radio } from './Radio'
export { default as RadioGroup } from './Radio/RadioGroup'
Expand All @@ -13,8 +13,8 @@ export { default as Tag } from './Tag'
export { default as InlineMessage } from './InlineMessage'
export { default as TextInput } from './TextInput'
export { default as Textarea } from './Textarea'
export { default as CloseButton } from './Buttons/CloseButton'
export { default as IconButton } from './Buttons/IconButton'
export { default as CloseButton } from './Forms/Buttons/CloseButton'
export { default as IconButton } from './Forms/Buttons/IconButton'
export { default as Slider } from './Slider'
export { default as QualitativeLegend } from './Legend/QualitativeLegend'
export { default as LayerParameters } from './Legend/LayerParameters'
Expand Down

0 comments on commit 086638d

Please sign in to comment.