Skip to content

Commit

Permalink
Clickui styled import fix ssr (#474)
Browse files Browse the repository at this point in the history
* Add styled component import fix

* Add jsx runtime to external to reduce package size

* Optimise code
  • Loading branch information
vineethasok authored Sep 16, 2024
1 parent 32d6a1e commit 0467d69
Show file tree
Hide file tree
Showing 79 changed files with 122 additions and 170 deletions.
28 changes: 14 additions & 14 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
href="https://fonts.googleapis.com/css?family=Inter&display=swap"
rel="stylesheet"
/>
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="https://fonts.googleapis.com/css?family=Inter&display=swap" rel="stylesheet" />
<title>Vite + React + TS</title>
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

</html>
1 change: 0 additions & 1 deletion public/vite.svg

This file was deleted.

2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import { ConfirmationDialog } from "@/components/ConfirmationDialog/Confirmation
import { ProgressBar } from "./components/ProgressBar/ProgressBar";
import GridExample from "./examples/GridExample";
import MultiAccordionDemo from "./components/MultiAccordion/MultiAccordionDemo";
import styled from "styled-components";
import { styled } from "styled-components";

const BackgroundWrapper = styled.div`
background: ${({ theme }) => theme.global.color.background.default};
Expand Down
3 changes: 2 additions & 1 deletion src/Introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Click UI has been tested in NextJS, Gatsby, and Vite. If you run into problems u
`npm i @clickhouse/click-ui`
or
`yarn add @clickhouse/click-ui`
2. Make sure to wrap your application in the Click UI `ClickUIProvider`, without doing this, you may run into issues with styled-components. Once thats done, you'll be able to import the individual components that you want to use on each page. Here's an example an `App.tsx` in NextJS.
2. Add styled-components and @types/react and @types/react-dom to package.json
3. Make sure to wrap your application in the Click UI `ClickUIProvider`, without doing this, you may run into issues with styled-components. Once thats done, you'll be able to import the individual components that you want to use on each page. Here's an example an `App.tsx` in NextJS.

```
import { Switch, Text, ThemeName, ClickUIProvider, Title } from '@clickhouse/click-ui'
Expand Down
17 changes: 0 additions & 17 deletions src/assets/RightArrow/RightArrow.tsx

This file was deleted.

31 changes: 0 additions & 31 deletions src/assets/S3Logo/S3Logo.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as RadixAccordion from "@radix-ui/react-accordion";
import styled from "styled-components";
import { styled } from "styled-components";
import { IconSize } from "@/components/Icon/types";
import { Icon, IconName, Spacer, Text } from "@/components";
import { ReactNode } from "react";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Alert/Alert.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Icon } from "@/components";
import { IconName } from "@/components/Icon/types";
import { useState, ReactNode } from "react";
import styled from "styled-components";
import { styled } from "styled-components";

type AlertType = "default" | "banner";
type AlertSize = "small" | "medium";
Expand Down
2 changes: 1 addition & 1 deletion src/components/AutoComplete/AutoComplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
SearchField,
Separator,
} from "@/components";
import styled from "styled-components";
import { styled } from "styled-components";
import { GenericMenuItem } from "../GenericMenu";
import { useOption, useSearch } from "./useOption";
import IconWrapper from "../IconWrapper/IconWrapper";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Image,
Root,
} from "@radix-ui/react-avatar";
import styled from "styled-components";
import { styled } from "styled-components";

type TextSize = "md" | "sm";

Expand Down
2 changes: 1 addition & 1 deletion src/components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled from "styled-components";
import { styled } from "styled-components";
import { HorizontalDirection } from "@/components";
import { HTMLAttributes, MouseEvent, ReactNode } from "react";
import { ImageName } from "@/components/Icon/types";
Expand Down
2 changes: 1 addition & 1 deletion src/components/BigStat/BigStat.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HTMLAttributes } from "react";
import styled from "styled-components";
import { styled } from "styled-components";
export type bigStatOrder = "titleTop" | "titleBottom";
export type bigStatSize = "sm" | "lg";
export type bigStatSpacing = "sm" | "lg";
Expand Down
38 changes: 19 additions & 19 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Icon, IconName } from "@/components";
import styled from "styled-components";
import { styled } from "styled-components";
import { BaseButton } from "../commonElement";
import React from "react";

Expand Down Expand Up @@ -41,25 +41,25 @@ export const Button = ({
{...delegated}
>
{!loading && (
<>
{iconLeft && (
<ButtonIcon
name={iconLeft}
aria-hidden
size="sm"
/>
)}
<>
{iconLeft && (
<ButtonIcon
name={iconLeft}
aria-hidden
size="sm"
/>
)}

{label ?? children}
{label ?? children}

{iconRight && (
<ButtonIcon
name={iconRight}
aria-hidden
size="sm"
/>
)}
</>
{iconRight && (
<ButtonIcon
name={iconRight}
aria-hidden
size="sm"
/>
)}
</>
)}
{loading && (
<LoadingIconWrapper data-testid="click-ui-loading-icon-wrapper">
Expand All @@ -68,7 +68,7 @@ export const Button = ({
data-testid="click-ui-loading-icon"
aria-label="loading"
></Icon>
{showLabelWithLoading? label ?? children : ""}
{showLabelWithLoading ? label ?? children : ""}
</LoadingIconWrapper>
)}
</StyledButton>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ButtonGroup/ButtonGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HTMLAttributes, ReactNode } from "react";
import styled, { DefaultTheme } from "styled-components";
import { DefaultTheme, styled } from "styled-components";

type ButtonGroupType = "default" | "borderless";

Expand Down
2 changes: 1 addition & 1 deletion src/components/CardHorizontal/CardHorizontal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HTMLAttributes, ReactNode } from "react";
import styled from "styled-components";
import { styled } from "styled-components";
import { Icon, IconName } from "@/components";

type CardColor = "default" | "muted";
Expand Down
2 changes: 1 addition & 1 deletion src/components/CardPrimary/CardPrimary.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled from "styled-components";
import { styled } from "styled-components";
import { Button, Icon, Spacer, IconName } from "@/components";
import { Title } from "@/components/Typography/Title/Title";
import { Text, TextAlignment } from "@/components/Typography/Text/Text";
Expand Down
2 changes: 1 addition & 1 deletion src/components/CardPrimary/CardPrimaryTopBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Badge } from "@/components/Badge/Badge";
import { Container } from "@/components/Container/Container";
import styled from "styled-components";
import { styled } from "styled-components";

export const TopBadgeWrapper = styled(Container)`
position: relative;
Expand Down
6 changes: 3 additions & 3 deletions src/components/CardPromotion/CardPromotion.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HTMLAttributes, useState } from "react";
import styled from "styled-components";
import { styled } from "styled-components";
import { Icon, IconName, Text } from "@/components";

export interface CardPromotionProps extends HTMLAttributes<HTMLDivElement> {
Expand Down Expand Up @@ -31,12 +31,12 @@ const Wrapper = styled.div<{
${({ theme }) => `
background: ${theme.click.card.promotion.color.background.default};
color: ${theme.click.card.promotion.color.text.default};
color: ${theme.click.card.promotion.color.text.default};
border-radius: ${theme.click.card.promotion.radii.all};
padding: ${theme.click.card.promotion.space.y} ${theme.click.card.promotion.space.x};
gap: ${theme.click.card.promotion.space.gap};
transition: .2s ease-in-out all;
&:hover {
background: ${theme.click.card.promotion.color.background.hover};
color: ${theme.click.card.promotion.color.text.hover};
Expand Down
7 changes: 5 additions & 2 deletions src/components/CardSecondary/CardSecondary.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled from "styled-components";
import { styled } from "styled-components";
import { Badge, Icon, IconName } from "@/components";
import { Title } from "@/components/Typography/Title/Title";
import { Text } from "@/components/Typography/Text/Text";
Expand Down Expand Up @@ -177,7 +177,10 @@ export const CardSecondary = ({
as={disabled || !infoUrl || infoUrl.length === 0 ? "div" : "a"}
>
<LinkText>{infoText}</LinkText>
<LinkIcon size={infoIconSize} name={infoIcon} />
<LinkIcon
size={infoIconSize}
name={infoIcon}
/>
</InfoLink>
)}
</Wrapper>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GenericLabel, Icon } from "@/components";
import * as RadixCheckbox from "@radix-ui/react-checkbox";
import { ReactNode, useId } from "react";
import styled from "styled-components";
import { styled } from "styled-components";
import { FormRoot } from "../commonElement";

export interface CheckboxProps extends RadixCheckbox.CheckboxProps {
Expand Down
2 changes: 1 addition & 1 deletion src/components/CodeBlock/CodeBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HTMLAttributes, useState } from "react";
import { Light as SyntaxHighlighter, createElement } from "react-syntax-highlighter";
import { IconButton } from "@/components";
import styled from "styled-components";
import { styled } from "styled-components";
import useColorStyle from "./useColorStyle";
import { EmptyButton } from "../commonElement";
import sql from "react-syntax-highlighter/dist/cjs/languages/hljs/sql";
Expand Down
2 changes: 1 addition & 1 deletion src/components/CodeBlock/InlineCodeBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HTMLAttributes } from "react";
import styled from "styled-components";
import { styled } from "styled-components";

const InlineContainer = styled.span`
${({ theme }) => `
Expand Down
2 changes: 1 addition & 1 deletion src/components/Collapsible/Collapsible.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
useEffect,
forwardRef,
} from "react";
import styled from "styled-components";
import { styled } from "styled-components";
import { Icon, HorizontalDirection, IconName } from "@/components";
import { EmptyButton } from "../commonElement";
import { IconWrapper } from "./IconWrapper";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Collapsible/IconWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ReactNode } from "react";
import styled from "styled-components";
import { styled } from "styled-components";
import { Icon, HorizontalDirection, IconName } from "@/components";

const LabelContainer = styled.span`
Expand Down
2 changes: 1 addition & 1 deletion src/components/ConfirmationDialog/ConfirmationDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Container, Dialog, Separator, Text } from "@/components";
import { ReactElement, ReactNode } from "react";
import styled from "styled-components";
import { styled } from "styled-components";

type DialogPrimaryAction = "primary" | "danger";

Expand Down
2 changes: 1 addition & 1 deletion src/components/Container/Container.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Container } from "./Container";
import { Text } from "..";
import styled from "styled-components";
import { styled } from "styled-components";

const GridCenter = styled.div`
display: grid;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Container/Container.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled from "styled-components";
import { styled } from "styled-components";
import {
ComponentProps,
ComponentPropsWithRef,
Expand Down
2 changes: 1 addition & 1 deletion src/components/ContextMenu/ContextMenu.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ContextMenuProps } from "@radix-ui/react-context-menu";
import { ContextMenu } from "./ContextMenu";
import styled from "styled-components";
import { styled } from "styled-components";

interface Props extends ContextMenuProps {
disabled?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/components/ContextMenu/ContextMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as RightMenu from "@radix-ui/react-context-menu";
import styled from "styled-components";
import { styled } from "styled-components";
import { HorizontalDirection, Icon, IconName } from "@/components";
import { Arrow, GenericMenuItem, GenericMenuPanel } from "../GenericMenu";
import PopoverArrow from "../icons/PopoverArrow";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialog/Dialog.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Dialog } from "./Dialog";
import Separator from "../Separator/Separator";
import { Spacer } from "../Spacer/Spacer";
import { Button } from "../Button/Button";
import styled from "styled-components";
import { styled } from "styled-components";
import { Link } from "../Link/Link";

const DialogComponent = ({
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReactNode } from "react";
import * as RadixDialog from "@radix-ui/react-dialog";
import styled, { keyframes } from "styled-components";
import { keyframes, styled } from "styled-components";
import { Button, Icon, Spacer } from "@/components";
import { CrossButton } from "../commonElement";
import { ButtonProps } from "@/components/Button/Button";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
import styled from "styled-components";
import { styled } from "styled-components";
import { HorizontalDirection, Icon, IconName } from "@/components";
import { Arrow, GenericMenuItem, GenericMenuPanel } from "../GenericMenu";
import PopoverArrow from "../icons/PopoverArrow";
Expand Down
2 changes: 1 addition & 1 deletion src/components/EllipsisContent/EllipsisContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
forwardRef,
} from "react";
import { mergeRefs } from "@/utils/mergeRefs";
import styled from "styled-components";
import { styled } from "styled-components";

const EllipsisContainer = styled.div`
display: inline-block;
Expand Down
2 changes: 1 addition & 1 deletion src/components/FileTabs/FileTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
WheelEvent,
useRef,
} from "react";
import styled from "styled-components";
import { styled } from "styled-components";
import { Icon, IconButton } from "@/components";
import { IconName } from "../Icon/types";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Flyout/Flyout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
Separator,
Spacer,
} from "@/components";
import styled from "styled-components";
import { styled } from "styled-components";
import { CrossButton } from "../commonElement";
import { keyframes } from "styled-components";

Expand Down
2 changes: 1 addition & 1 deletion src/components/GenericLabel/GenericLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HTMLAttributes } from "react";
import styled from "styled-components";
import { styled } from "styled-components";

export interface GenericLabelProps extends HTMLAttributes<HTMLLabelElement> {
disabled?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/components/GenericMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled from "styled-components";
import { styled } from "styled-components";

export const GenericMenuPanel = styled.div<{
$type: "popover" | "dropdown-menu" | "context-menu";
Expand Down Expand Up @@ -112,7 +112,7 @@ export const GenericMenuItem = styled.div`
&:visited {
color: ${theme.click.genericMenu.item.color.text.default};
a {
color: ${theme.click.genericMenu.item.color.text.default};
color: ${theme.click.genericMenu.item.color.text.default};
}
}
`};
Expand Down
Loading

0 comments on commit 0467d69

Please sign in to comment.