Skip to content

Commit

Permalink
chore: update stories to reflect xs size and tweak select icon style …
Browse files Browse the repository at this point in the history
…for xs
  • Loading branch information
segunadebayo committed Jan 6, 2021
1 parent 7442a50 commit e9e5e3a
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 44 deletions.
2 changes: 1 addition & 1 deletion packages/input/stories/input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const Controlled = () => {

export const WithSizes = () => (
<Stack align="start">
{["sm", "md", "lg"].map((size) => (
{["xs", "sm", "md", "lg"].map((size) => (
<Input size={size} placeholder="This is an input component" />
))}
</Stack>
Expand Down
32 changes: 9 additions & 23 deletions packages/number-input/stories/number-input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,29 +159,15 @@ export const allowOutOfRange = () => (

export const inputSizes = () => (
<Stack>
<NumberInput size="sm" defaultValue={15} min={10}>
<NumberInputField />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />
</NumberInputStepper>
</NumberInput>

<NumberInput size="md" defaultValue={15} min={10}>
<NumberInputField />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />
</NumberInputStepper>
</NumberInput>

<NumberInput size="lg" defaultValue={15} min={10}>
<NumberInputField />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />
</NumberInputStepper>
</NumberInput>
{["xs", "sm", "md", "lg"].map((size) => (
<NumberInput key={size} size={size} defaultValue={15} min={10}>
<NumberInputField />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />
</NumberInputStepper>
</NumberInput>
))}
</Stack>
)

Expand Down
4 changes: 2 additions & 2 deletions packages/pin-input/stories/pin-input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export function ComponentExample() {

export const Sizes = () => (
<>
{["sm", "md", "lg"].map((size, i) => (
<div key={i} style={{ marginBottom: "1rem" }}>
{["xs", "sm", "md", "lg"].map((size) => (
<div key={size} style={{ marginBottom: "1rem" }}>
<PinInput size={size} defaultValue="234">
<PinInputField />
<PinInputField />
Expand Down
3 changes: 0 additions & 3 deletions packages/select/src/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,8 @@ const IconWrapper = chakra("div", {
baseStyle: {
position: "absolute",
display: "inline-flex",
width: "1.5rem",
height: "100%",
alignItems: "center",
justifyContent: "center",
right: "0.5rem",
pointerEvents: "none",
top: "50%",
transform: "translateY(-50%)",
Expand Down
12 changes: 6 additions & 6 deletions packages/select/stories/select.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ export const SelectVariants = () => (

export const SelectSizes = () => (
<Stack spacing={4}>
<Select placeholder="large size" size="lg" />
<Select placeholder="default size" size="md" />
<Select placeholder="small size" size="sm" />
{["xs", "sm", "md", "lg"].map((size) => (
<Select placeholder={`${size} size`} size={size} key={size} />
))}
</Stack>
)

Expand Down Expand Up @@ -103,9 +103,9 @@ const UpDownIcon = (props: any) => (
</svg>
)

export const SelectIcon = () => {
return <Select icon={<UpDownIcon />} placeholder="Placeholder" size="md" />
}
export const SelectIcon = () => (
<Select icon={<UpDownIcon />} placeholder="Placeholder" size="md" />
)

export const FocusAndErrorColors = () => (
<Stack>
Expand Down
7 changes: 6 additions & 1 deletion packages/textarea/stories/textarea.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { chakra } from "@chakra-ui/system"
import * as React from "react"
import { Textarea } from "../src"
import { chakra } from "@chakra-ui/system"

export default {
title: "Textarea",
Expand Down Expand Up @@ -29,6 +29,11 @@ export const invalid = () => (

export const withSizes = () => (
<>
<Textarea
size="xs"
placeholder="A sample placeholder"
defaultValue="This is a x-small textarea"
/>
<Textarea
size="sm"
placeholder="A sample placeholder"
Expand Down
3 changes: 2 additions & 1 deletion packages/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"lint:types": "tsc --noEmit"
},
"dependencies": {
"@chakra-ui/theme-tools": "1.0.2"
"@chakra-ui/theme-tools": "1.0.2",
"@chakra-ui/utils": "1.0.2"
},
"peerDependencies": {
"@chakra-ui/system": ">=1.0.0"
Expand Down
27 changes: 20 additions & 7 deletions packages/theme/src/components/select.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { mode } from "@chakra-ui/theme-tools"
import { mergeWith as merge } from "@chakra-ui/utils"
import Input from "./input"

const { sizes, defaultProps, variants } = Input

const parts = ["field", "icon"]

function baseStyleField(props: Record<string, any>) {
Expand All @@ -17,21 +16,35 @@ function baseStyleField(props: Record<string, any>) {
}
}

const baseStyleInput = {
const baseStyleIcon = {
width: "1.5rem",
height: "100%",
right: "0.5rem",
position: "relative",
color: "currentColor",
fontSize: "1.25rem",
_disabled: { opacity: 0.5 },
_disabled: {
opacity: 0.5,
},
}

const baseStyle = (props: Record<string, any>) => ({
field: baseStyleField(props),
icon: baseStyleInput,
icon: baseStyleIcon,
})

const sizes = merge({}, Input.sizes, {
xs: {
icon: {
right: "0.25rem",
},
},
})

export default {
parts,
baseStyle,
sizes,
variants,
defaultProps,
variants: Input.variants,
defaultProps: Input.defaultProps,
}

0 comments on commit e9e5e3a

Please sign in to comment.