Skip to content

Commit

Permalink
refactor(build): no React import needed (#428)
Browse files Browse the repository at this point in the history
* refactor(build): no React import needed
* Less use of FC
* refactor(notifications\): remove old notifications

BREAKING CHANGE: NotificationManager, NotificationContainer, Notification
  • Loading branch information
ehsan-github authored Jun 7, 2023
1 parent e064669 commit 60ce090
Show file tree
Hide file tree
Showing 210 changed files with 261 additions and 770 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ yarn add @logicalclocks/quartz
### Usage

```tsx
import React from 'react';

import { ThemeProvider, Button } from '@logicalclocks/quartz';

const App = () => (
Expand Down Expand Up @@ -103,10 +101,9 @@ Delete `node_modules` and `dist` folders then follow **Build locally** or **Run

Follow **Build locally** or **Run locally** instruction


## Using locally

You can use the library locally with the help of [yalc](https://github.com/wclr/yalc).
Just run `yarn publish-local` here and then do a `yalc link @logicalclocks/quartz` wherever you wanna use it.

To publish changes you can do `yarn dlx yalc push`. After that, the changes will be "published" to the local registry.

4 changes: 2 additions & 2 deletions src/components/alternative-header/AlternativeHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, useMemo } from 'react';
import React, { useMemo } from 'react';
import { Box, BoxProps, Flex } from 'rebass';
import Value from '../typography/value';
import * as S from './styles';
Expand All @@ -23,7 +23,7 @@ export interface Props extends Omit<BoxProps, 'css'> {
withBase?: boolean;
}

export const AlternativeHeader: FC<Props> = ({
export const AlternativeHeader = ({
title,
tabs,
withBase = false,
Expand Down
2 changes: 1 addition & 1 deletion src/components/alternative-header/stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Meta, StoryObj } from '@storybook/react';
import React, { useMemo, useState } from 'react';
import { useMemo, useState } from 'react';
import { Box } from 'rebass';
import { AlternativeHeader } from './index';

Expand Down
1 change: 0 additions & 1 deletion src/components/animated-progress/AnimatedProgress.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { useNProgress } from '@tanem/react-nprogress';
import { Options } from '@tanem/react-nprogress/dist/types';

Expand Down
6 changes: 3 additions & 3 deletions src/components/animated-progress/Bar.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import { Flex } from 'rebass';

const Bar: React.FC<{
interface Props {
animationDuration: number;
progress: number;
variant: string;
}> = ({ animationDuration, progress, variant }) => (
}
const Bar = ({ animationDuration, progress, variant }: Props) => (
<Flex
variant={variant}
sx={{
Expand Down
1 change: 0 additions & 1 deletion src/components/animated-progress/Container.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { Flex } from 'rebass';

const Container = ({ children }: React.PropsWithChildren) => (
Expand Down
2 changes: 1 addition & 1 deletion src/components/animated-progress/stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Meta, StoryObj } from '@storybook/react';
import React, { useState } from 'react';
import { useState } from 'react';
import { Box } from '../box';
import { Button } from '../button';
import { Flex } from '../flex';
Expand Down
1 change: 0 additions & 1 deletion src/components/badge/Badge.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { Flex, FlexProps, SxStyleProp } from 'rebass';
import { useTheme } from '../../theme/theme';
import { getIcon, IconName } from '../icon/list';
Expand Down
1 change: 0 additions & 1 deletion src/components/badge/stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Meta, StoryObj } from '@storybook/react';
import React from 'react';
import { Badge } from './Badge';
import { IconName } from '../icon/list';

Expand Down
1 change: 0 additions & 1 deletion src/components/bar/Bar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import * as R from 'ramda';

import { Box, BoxProps } from '../box';
Expand Down
1 change: 0 additions & 1 deletion src/components/bar/stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Meta, StoryObj } from '@storybook/react';
import React from 'react';
import { Flex } from '../flex';
import { Bar } from './Bar';

Expand Down
14 changes: 8 additions & 6 deletions src/components/box/Box.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React, { FC, forwardRef } from 'react';
import { PropsWithChildren, forwardRef } from 'react';
import { Box as RebassBox, BoxProps } from 'rebass';

export interface Props extends Omit<BoxProps, 'css'> {}

export const Box: FC<Props> = forwardRef(({ children, ...rest }, ref) => (
<RebassBox ref={ref} {...rest}>
{children}
</RebassBox>
));
export const Box = forwardRef(
({ children, ...rest }: PropsWithChildren<Props>, ref) => (
<RebassBox ref={ref} {...rest}>
{children}
</RebassBox>
),
);
1 change: 0 additions & 1 deletion src/components/button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as R from 'ramda';
import React from 'react';
import { Button as RebassButton, ButtonProps } from 'rebass';

// Styles
Expand Down
1 change: 0 additions & 1 deletion src/components/button/stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { action } from '@storybook/addon-actions';
import React from 'react';
import { StoryObj, Meta } from '@storybook/react';

import { Button } from './Button';
Expand Down
8 changes: 1 addition & 7 deletions src/components/callout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React, { FC } from 'react';
import { Box, Flex, FlexProps, Text } from 'rebass';
import styles from './callout.styles';
import { Color } from '../../theme/types';
Expand All @@ -23,12 +22,7 @@ export interface ICalloutProps extends Omit<FlexProps, 'content' | 'css'> {
cta?: React.ReactNode;
}

const Callout: FC<ICalloutProps> = ({
type,
content,
cta,
...props
}: ICalloutProps) => (
const Callout = ({ type, content, cta, ...props }: ICalloutProps) => (
<Flex
width="100%"
variant={`callout.${type}`}
Expand Down
1 change: 0 additions & 1 deletion src/components/callout/stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { Meta, StoryObj } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { Box } from 'rebass';
Expand Down
3 changes: 1 addition & 2 deletions src/components/calloutWithButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React, { FC } from 'react';
import { FlexProps } from 'rebass';
import Callout, { CalloutTypes } from '../callout';
import { Button } from '../button';
Expand All @@ -14,7 +13,7 @@ export interface ICalloutWithButtonProps
isButtonLoading?: boolean;
}

const CalloutWithButton: FC<ICalloutWithButtonProps> = ({
const CalloutWithButton = ({
buttonContent,
content,
onClick,
Expand Down
5 changes: 2 additions & 3 deletions src/components/card-header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React, { FC } from 'react';
import { Box, BoxProps, Flex } from 'rebass';
import styles from './card-header.styles';

Expand All @@ -8,13 +7,13 @@ export interface CardHeaderProps extends Omit<BoxProps, 'title' | 'css'> {
withShadow?: boolean;
withBorderBottom?: boolean;
}
const CardHeader: FC<CardHeaderProps> = ({
const CardHeader = ({
title,
actions,
withShadow = false,
withBorderBottom = false,
...props
}) => (
}: CardHeaderProps) => (
<Box {...props} sx={{ ...styles(withShadow, withBorderBottom), ...props.sx }}>
{title && (
<Flex alignItems="center" as="h4">
Expand Down
1 change: 0 additions & 1 deletion src/components/card-header/stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { action } from '@storybook/addon-actions';

import { Box, Button } from 'rebass';
Expand Down
4 changes: 2 additions & 2 deletions src/components/card/card-secondary.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, memo, useEffect, useRef, useState } from 'react';
import { memo, useEffect, useRef, useState } from 'react';
import {
Box,
Flex,
Expand All @@ -18,7 +18,7 @@ export interface CardSecondaryProps
readonly?: boolean;
}

const CardSecondary: FC<CardSecondaryProps> = ({
const CardSecondary = ({
title,
children,
maxHeight,
Expand Down
4 changes: 2 additions & 2 deletions src/components/card/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, memo, useRef } from 'react';
import { memo, useRef } from 'react';
import { Box, Card as RebassCard, CardProps as RebassCardProps } from 'rebass';

// Styles
Expand All @@ -20,7 +20,7 @@ export interface CardProps extends Omit<RebassCardProps, 'css' | 'title'> {
expandable?: boolean;
}

const Card: FC<CardProps> = ({
const Card = ({
title,
actions,
children,
Expand Down
1 change: 0 additions & 1 deletion src/components/card/stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { action } from '@storybook/addon-actions';
import React from 'react';
import { Meta, StoryObj } from '@storybook/react';

import Card from '.';
Expand Down
5 changes: 2 additions & 3 deletions src/components/checkbox/checkbox-group.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { FC, useCallback } from 'react';
import { useCallback } from 'react';

// Components
import Label, { LabelProps } from '../label';
import Checkbox from './index';
import { TooltipProps } from '../tooltip';
Expand All @@ -15,7 +14,7 @@ export interface CheckboxGroupProps
tooltipProps?: Omit<TooltipProps, 'children'>;
}

const CheckboxGroup: FC<CheckboxGroupProps> = ({
const CheckboxGroup = ({
label,
options,
value,
Expand Down
2 changes: 1 addition & 1 deletion src/components/checkbox/group.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import { useState } from 'react';
import { Meta, StoryObj } from '@storybook/react';
import CheckboxGroup from './checkbox-group';

Expand Down
6 changes: 2 additions & 4 deletions src/components/checkbox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { CheckboxProps as RebassCheckboxProps } from '@rebass/forms';
import React, { FC, forwardRef } from 'react';
import { forwardRef } from 'react';
import { Box, Flex } from 'rebass';

// Components
import Labeling from '../typography/labeling';
// Styles
import styles from './checkbox-styles';
import Tooltip, { TooltipProps } from '../tooltip';

Expand All @@ -14,7 +12,7 @@ export interface CheckboxProps extends Omit<RebassCheckboxProps, 'css'> {
tooltipProps?: Omit<TooltipProps, 'children'>;
}

const Checkbox: FC<CheckboxProps> = forwardRef(
const Checkbox = forwardRef(
(
{
label,
Expand Down
1 change: 0 additions & 1 deletion src/components/checkbox/stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { Meta, StoryObj } from '@storybook/react';
import Checkbox from './index';

Expand Down
4 changes: 2 additions & 2 deletions src/components/code-input/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, forwardRef } from 'react';
import { forwardRef } from 'react';
import { Box, Flex } from 'rebass';

import { loadLanguage } from '@uiw/codemirror-extensions-langs';
Expand Down Expand Up @@ -31,7 +31,7 @@ export interface CodeInputProps
intent?: Intents;
}

const CodeInput: FC<CodeInputProps> = forwardRef(
const CodeInput = forwardRef(
({
label = '',
value,
Expand Down
1 change: 0 additions & 1 deletion src/components/code-input/stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { action } from '@storybook/addon-actions';
import { Meta, StoryObj } from '@storybook/react';
import React from 'react';

import CodeInput from '.';

Expand Down
2 changes: 0 additions & 2 deletions src/components/code/code.styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

export const boxStyles: React.CSSProperties = {
width: '100%',
lineHeight: '16px',
Expand Down
2 changes: 1 addition & 1 deletion src/components/code/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EditorView } from '@codemirror/view';
import React, { useState } from 'react';
import { useState } from 'react';
import { Box, Flex, FlexProps } from 'rebass';

import { LanguageName, loadLanguage } from '@uiw/codemirror-extensions-langs';
Expand Down
1 change: 0 additions & 1 deletion src/components/code/stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { StoryObj, Meta } from '@storybook/react';
import { Box } from 'rebass';
import Code, { defaultPopupProps } from './index';
Expand Down
6 changes: 3 additions & 3 deletions src/components/collapse/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { memo, useEffect, useRef, useState } from 'react';
import { Box, BoxProps, Flex } from 'rebass';
import React, { FC, memo, useEffect, useRef, useState } from 'react';

import Labeling from '../typography/labeling';
import styles, { contentStyles, containerStyles } from './collapse.styles';
Expand All @@ -13,15 +13,15 @@ export interface CollapseProps extends Omit<BoxProps, 'css' | 'title'> {
openChange?: (value: boolean) => void;
}

const Collapse: FC<CollapseProps> = ({
const Collapse = ({
title,
contentProps,
secondaryContent,
children,
isOpenProps = false,
openChange,
...props
}) => {
}: CollapseProps) => {
const containerRef = useRef<HTMLDivElement>(null);
const contentRef = useRef<HTMLDivElement>(null);

Expand Down
1 change: 0 additions & 1 deletion src/components/collapse/stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { Box } from 'rebass';
import { StoryObj, Meta } from '@storybook/react';

Expand Down
6 changes: 3 additions & 3 deletions src/components/compact-button/compact-button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, memo, CSSProperties } from 'react';
import { memo, CSSProperties } from 'react';
import { Button, ButtonProps, Flex, Box } from 'rebass';
import { GetIcon, IconName } from '../icon';

Expand Down Expand Up @@ -30,7 +30,7 @@ const getLinkProps = ({ href, newTab }: LinkRelatedProps): Partial<Props> =>
}
: {};

const CompactButton: FC<Props> = ({
const CompactButton = ({
icon,
href,
children,
Expand All @@ -40,7 +40,7 @@ const CompactButton: FC<Props> = ({
newTab = false,
mode = 'default',
...props
}) => (
}: Props) => (
<Button
{...props}
{...getLinkProps({ newTab, href })}
Expand Down
1 change: 0 additions & 1 deletion src/components/compact-button/stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { StoryObj, Meta } from '@storybook/react';

import CompactButton from '.';
Expand Down
6 changes: 3 additions & 3 deletions src/components/datepicker/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, forwardRef, memo, useState } from 'react';
import { forwardRef, memo, useState } from 'react';
import ReactDatePicker, { ReactDatePickerProps } from 'react-datepicker';
import { Flex, SxStyleProp } from 'rebass';

Expand All @@ -19,12 +19,12 @@ export interface DatePickerProps extends ReactDatePickerProps {
const getPlacement = (align: DatePickerProps['datePickerAlign']) =>
align === 'right' ? 'bottom-end' : 'bottom-start';

const DatePicker: FC<DatePickerProps> = ({
const DatePicker = ({
selectProps,
datePickerAlign = 'right',
sx,
...props
}) => {
}: DatePickerProps) => {
const [isOpen, setOpen] = useState(false);
return (
<Flex flexDirection="column" sx={{ ...styles, ...sx }}>
Expand Down
Loading

0 comments on commit 60ce090

Please sign in to comment.