Skip to content

Commit

Permalink
feat(ButtonPrimitive): migrate to Tailwind
Browse files Browse the repository at this point in the history
  • Loading branch information
oreqizer authored and DSil committed Oct 2, 2023
1 parent 5faa7bd commit 4ea8178
Show file tree
Hide file tree
Showing 12 changed files with 278 additions and 369 deletions.
9 changes: 4 additions & 5 deletions docs/src/components/BrandedTile.tsx
@@ -1,6 +1,5 @@
import React from "react";
import { Heading, Stack, Button, mediaQueries as mq } from "@kiwicom/orbit-components";
import { StyledButtonPrimitive } from "@kiwicom/orbit-components/lib/primitives/ButtonPrimitive";
import useTheme from "@kiwicom/orbit-components/lib/hooks/useTheme";
import styled, { css } from "styled-components";

Expand Down Expand Up @@ -40,18 +39,18 @@ const StyledWrapper = styled.a<{ primary: string; type?: "primary" | "secondary"
${boxShadowActive};
}
${StyledButtonPrimitive} {
.orbit-button-primitive {
pointer-events: none;
background: ${getBgColor({ theme, type, color })};
}
&:hover ${StyledButtonPrimitive} {
&:hover .orbit-button-primitive {
background: ${getBgColorHover({ theme, type, color })}
}
&:focus ${StyledButtonPrimitive} {
&:focus .orbit-button-primitive {
background: ${getBgColor({ theme, type, color })}
}
&:active ${StyledButtonPrimitive} {
&:active .orbit-button-primitive {
background: ${getBgColorActive({ theme, type, color })}
}
`};
Expand Down
5 changes: 2 additions & 3 deletions packages/orbit-components/src/ButtonGroup/index.tsx
Expand Up @@ -5,14 +5,13 @@ import styled, { css } from "styled-components";

import defaultTheme from "../defaultTheme";
import { borderRadius, rtlSpacing } from "../utils/rtl";
import { StyledButtonPrimitive } from "../primitives/ButtonPrimitive";
import mq from "../utils/mediaQuery";
import type { Props } from "./types";

const StyledButtonGroup = styled.div`
display: flex;
${StyledButtonPrimitive} {
.orbit-button-primitive {
border-radius: 0;
margin: ${({ theme }) => rtlSpacing(theme.orbit.marginButtonGroup)};
Expand All @@ -26,7 +25,7 @@ const StyledButtonGroup = styled.div`
}
}
${mq.tablet(css`
${StyledButtonPrimitive} {
.orbit-button-primitive {
:first-child {
border-radius: ${({ theme }) =>
borderRadius(`${theme.orbit.borderRadiusNormal} 0 0 ${theme.orbit.borderRadiusNormal}`)};
Expand Down
5 changes: 2 additions & 3 deletions packages/orbit-components/src/InputField/index.tsx
Expand Up @@ -19,7 +19,6 @@ import InformationCircle from "../icons/InformationCircle";
import FormLabel from "../FormLabel";
import useErrorTooltip from "../ErrorFormTooltip/hooks/useErrorTooltip";
import formElementFocus from "./helpers/formElementFocus";
import { StyledButtonPrimitiveIconContainer } from "../primitives/ButtonPrimitive/components/ButtonPrimitiveIconContainer";
import mq from "../utils/mediaQuery";
import type { Props } from "./types";

Expand Down Expand Up @@ -187,7 +186,7 @@ export const Prefix = styled(({ children, className, iconRef }) => (
height: ${theme.orbit.heightIconNormal};
}
${StyledButtonPrimitiveIconContainer} {
.orbit-button-primitive-icon {
color: ${theme.orbit.colorIconSecondary};
}
`}
Expand All @@ -208,7 +207,7 @@ const Suffix = styled(({ children, className }) => <div className={className}>{c
pointer-events: ${disabled && "none"};
z-index: 3;
${StyledButtonPrimitiveIconContainer} {
.orbit-button-primitive-icon {
color: ${theme.orbit.colorIconSecondary};
}
Expand Down
3 changes: 1 addition & 2 deletions packages/orbit-components/src/Modal/ModalFooter/index.tsx
Expand Up @@ -10,7 +10,6 @@ import { rtlSpacing } from "../../utils/rtl";
import { ModalContext } from "../ModalContext";
import { QUERIES } from "../../utils/mediaQuery/consts";
import useModalContextFunctions from "../helpers/useModalContextFunctions";
import { StyledButtonPrimitive } from "../../primitives/ButtonPrimitive";
import type { Props } from "./types";

const StyledChild = styled.div<{ flex?: Props["flex"] }>`
Expand Down Expand Up @@ -38,7 +37,7 @@ export const StyledModalFooter = styled.div<{
box-sizing: border-box;
transition: ${transition(["box-shadow"], "fast", "ease-in-out")};
@media (max-width: ${+getBreakpointWidth(QUERIES.LARGEMOBILE, theme, true) - 1}px) {
${StyledButtonPrimitive} {
.orbit-button-primitive {
font-size: ${theme.orbit.fontSizeButtonNormal};
height: ${theme.orbit.heightButtonNormal};
}
Expand Down
3 changes: 1 addition & 2 deletions packages/orbit-components/src/Modal/index.tsx
Expand Up @@ -11,7 +11,6 @@ import ModalCloseButton from "./ModalCloseButton";
import { SIZES, CLOSE_BUTTON_DATA_TEST } from "./consts";
import KEY_CODE_MAP from "../common/keyMaps";
import defaultTheme from "../defaultTheme";
import { StyledButtonPrimitive } from "../primitives/ButtonPrimitive";
import media from "../utils/mediaQuery";
import { right } from "../utils/rtl";
import transition from "../utils/transition";
Expand Down Expand Up @@ -151,7 +150,7 @@ const CloseContainer = styled.div<{
margin: 0;
}
${StyledButtonPrimitive} {
.orbit-button-primitive {
pointer-events: auto;
margin-${right}: ${theme.orbit.spaceXXSmall};
Expand Down
Expand Up @@ -13,7 +13,6 @@ import transition from "../../utils/transition";
import useClickOutside from "../../hooks/useClickOutside";
import useLockScrolling from "../../hooks/useLockScrolling";
import { ModalContext } from "../../Modal/ModalContext";
import { StyledButtonPrimitive } from "../../primitives/ButtonPrimitive";
import { PLACEMENTS } from "../../common/consts";
import boundingClientRect from "../../utils/boundingClientRect";
import type { Offset } from "../types";
Expand Down Expand Up @@ -82,7 +81,7 @@ const StyledActions = styled.div`
padding: ${popoverPadding};
padding-top: ${theme.orbit.spaceSmall};
background-color: ${theme.orbit.paletteWhite};
${StyledButtonPrimitive} {
.orbit-button-primitive {
width: 100%;
flex: 1 1 auto;
}
Expand All @@ -92,7 +91,7 @@ const StyledActions = styled.div`
left: auto;
border-bottom-left-radius: ${theme.orbit.borderRadiusNormal};
border-bottom-right-radius: 3px;
${StyledButtonPrimitive} {
.orbit-button-primitive {
width: auto;
flex-grow: 0;
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Expand Up @@ -3,7 +3,6 @@
DOCUMENTATION: https://orbit.kiwi/utilities/buttonprimitive/
*/
import * as React from "react";
import type { StyledComponent } from "styled-components";

import type { Globals, Component } from "../../common/common.js.flow";
import type { spaceAfter } from "../../common/getSpacingToken/index.js.flow";
Expand Down Expand Up @@ -110,6 +109,4 @@ export type Props = {|
...PrimitiveTypes,
|};

declare export var StyledButtonPrimitive: StyledComponent<any, any, HTMLElement>;

declare export default React.AbstractComponent<Props, HTMLButtonElement>;

0 comments on commit 4ea8178

Please sign in to comment.