Skip to content

Commit

Permalink
refactor(shared/system): export default에서 export로 방식 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
sukvvon committed Mar 24, 2024
1 parent 38c02c7 commit 49d5709
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 21 deletions.
6 changes: 2 additions & 4 deletions packages/shared/system/src/createComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ import {
type ElementType,
createElement,
} from 'react';
import forwardRef from './forwardRef';
import { forwardRef } from './forwardRef';
import { type ComponentWithAs, type DOMElements } from './types';

export type FavolinkComponent<Element extends DOMElements> = ComponentWithAs<
Element,
object
>;

export default function createComponent<Element extends DOMElements>(
element: Element,
) {
export function createComponent<Element extends DOMElements>(element: Element) {
const favolinkComponent = forwardRef(function favolinkComponent(props, ref) {
const { as: asElement, ...restProps } = props;

Expand Down
2 changes: 1 addition & 1 deletion packages/shared/system/src/createContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type CreateContextReturn<CreateContextDefaultValue> = [
Context<CreateContextDefaultValue>,
];

export default function createContext<CreateContextDefaultValue>(
export function createContext<CreateContextDefaultValue>(
defaultValue: CreateContextDefaultValue,
): CreateContextReturn<CreateContextDefaultValue> {
const Context = createReactContext<CreateContextDefaultValue>(defaultValue);
Expand Down
9 changes: 5 additions & 4 deletions packages/shared/system/src/createIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { Children, type ComponentPropsWithoutRef, type ReactNode } from 'react';
import { Children, type ReactNode } from 'react';
import { type HTMLFavolinkProps } from './createComponent';
import { favolink } from './factory';
import forwardRef from './forwardRef';
import { forwardRef } from './forwardRef';

type IconProps = ComponentPropsWithoutRef<'svg'>;
type IconProps = HTMLFavolinkProps<'svg'>;

type CreateIconOptions = {
d?: string;
path?: ReactNode | ReactNode[];
defaultProps?: IconProps;
};

export default function createIcon(options: CreateIconOptions) {
export function createIcon(options: CreateIconOptions) {
const { d: pathDefinition, path, defaultProps = {} } = options;
const { viewBox = '0 0 20 20', ...restDefaultProps } = defaultProps;

Expand Down
3 changes: 2 additions & 1 deletion packages/shared/system/src/factory.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import createComponent, {
import {
type FavolinkComponent,
type HTMLFavolinkComponents,
createComponent,
} from './createComponent';
import { type DOMElements } from './types';

Expand Down
5 changes: 1 addition & 4 deletions packages/shared/system/src/forwardRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import {
} from 'react';
import { type ComponentWithAs, type RightJoinProps } from './types';

export default function forwardRef<
Props extends object,
Component extends ElementType,
>(
export function forwardRef<Props extends object, Component extends ElementType>(
render: ForwardRefRenderFunction<
any,
RightJoinProps<ComponentPropsWithoutRef<Component>, Props> & {
Expand Down
11 changes: 4 additions & 7 deletions packages/shared/system/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/* eslint-disable @stylistic/padding-line-between-statements */
export { default as createComponent } from './createComponent';
export {
default as createContext,
type ContextProviderProps,
} from './createContext';
export { default as createIcon } from './createIcon';
export * from './createComponent';
export * from './createContext';
export * from './createIcon';
export * from './factory';
export { default as forwardRef } from './forwardRef';
export * from './forwardRef';
export * from './types';

0 comments on commit 49d5709

Please sign in to comment.