Skip to content

Commit

Permalink
Reorganize components
Browse files Browse the repository at this point in the history
  • Loading branch information
fverloop committed Apr 11, 2019
1 parent 06ac9ba commit 3ed50f8
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 39 deletions.
35 changes: 19 additions & 16 deletions design-system/src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from "react"
import { theme } from "../theme"
import styled from "styled-components"

// Types
export type Props = {
/** Optional string that can be used to set the button value */
text?: string
Expand All @@ -16,6 +17,24 @@ export type Props = {
kind?: "default" | "primary" | "danger"
}

// Component
export const Button: React.FC<Props> = ({
text,
fluid,
disabled,
children,
kind
}) => (
<StyledButton
className={`${fluid ? "fluid" : ""} ${disabled ? "disabled" : ""} ${
kind ? kind : ""
}`}
>
{text || children}
</StyledButton>
)

// Styles
const StyledButton = styled.button`
background: ${theme.color.paneBg};
border-radius: 4px;
Expand Down Expand Up @@ -85,19 +104,3 @@ const StyledButton = styled.button`
inset 0px 0px 0px 1px hsla(0, 0%, 0%, 0.05);
}
`

export const Button: React.FC<Props> = ({
text,
fluid,
disabled,
children,
kind
}) => (
<StyledButton
className={`${fluid ? "fluid" : ""} ${disabled ? "disabled" : ""} ${
kind ? kind : ""
}`}
>
{text || children}
</StyledButton>
)
35 changes: 19 additions & 16 deletions design-system/src/components/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from "react"
import { theme } from "../theme"
import styled from "styled-components"

// Types
export type Props = {
/** Input text */
value?: string
Expand All @@ -19,6 +20,24 @@ export type Props = {
onChange?: any
}

// Component
export const Input: React.FC<Props> = ({
value,
placeholder,
error,
disabled,
onChange
}) => (
<StyledInput
type="text"
value={value}
placeholder={placeholder}
className={`${error ? "error" : ""} ${disabled ? "disabled" : ""}`}
onChange={onChange}
/>
)

// Styles
const StyledInput = styled.input`
background: ${theme.color.paneBgDark};
border-radius: 4px;
Expand Down Expand Up @@ -64,19 +83,3 @@ const StyledInput = styled.input`
opacity: 0.5;
}
`

export const Input: React.FC<Props> = ({
value,
placeholder,
error,
disabled,
onChange
}) => (
<StyledInput
type="text"
value={value}
placeholder={placeholder}
className={`${error ? "error" : ""} ${disabled ? "disabled" : ""}`}
onChange={onChange}
/>
)
17 changes: 10 additions & 7 deletions design-system/src/components/Toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from "react"
import { theme } from "../theme"
import styled from "styled-components"

// Types
export type Props = {
/** Disable Toggle */
disabled?: boolean
Expand All @@ -13,6 +14,15 @@ export type Props = {
onClick?: React.MouseEventHandler<HTMLDivElement>
}

// Component
export const Toggle: React.FC<Props> = ({ disabled, active, onClick }) => (
<StyledToggle
className={`${disabled ? "disabled" : ""} ${active ? "active" : ""}`}
onClick={onClick}
/>
)

// Styling
const StyledToggle = styled.span`
background: ${theme.color.paneBgDark};
border-radius: 100px;
Expand Down Expand Up @@ -54,10 +64,3 @@ const StyledToggle = styled.span`
opacity: 0.5;
}
`

export const Toggle: React.FC<Props> = ({ disabled, active, onClick }) => (
<StyledToggle
className={`${disabled ? "disabled" : ""} ${active ? "active" : ""}`}
onClick={onClick}
/>
)

0 comments on commit 3ed50f8

Please sign in to comment.