Skip to content

Commit

Permalink
fix: update get prefix order
Browse files Browse the repository at this point in the history
  • Loading branch information
wwsun committed Jan 12, 2022
1 parent 8a3ef57 commit 5f9a773
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
6 changes: 1 addition & 5 deletions src/coral.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import styled from 'styled-components';
import { shouldForwardProp, cssProps, allStyledProps } from './core';
import type { CoralProps, As, CoralComponent } from './types';
import { DEFAULT_PREFIX } from './helpers';

interface CoralOption<P> {
/**
Expand All @@ -21,14 +20,11 @@ interface CoralOption<P> {
}

export function coral<T extends As, P = {}>(component: T, css?: CoralProps['css'], options?: CoralOption<P>) {
const prefix = options?.prefix || DEFAULT_PREFIX;
const attrs = typeof options?.attrs === 'function' ? options?.attrs : () => options?.attrs;
console.log(attrs);
const shouldForward = options?.shouldForwardProp || shouldForwardProp;

return styled(component as React.ComponentType<any>)
.attrs((props) => ({
prefix: props.prefix || prefix,
prefix: props.prefix || options?.prefix,
...attrs(props),
}))
.withConfig({
Expand Down
3 changes: 1 addition & 2 deletions src/core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ export const compose = (...parsers: any[]) => {
function createParser(config: any) {
const parse = (props: Record<string, any>) => {
const styles = {};

const prefix = props.theme?.prefix || props.prefix || DEFAULT_PREFIX;
const prefix = props.prefix || props.theme?.prefix || DEFAULT_PREFIX;

for (const key in props) {
if (key === 'theme') continue;
Expand Down

0 comments on commit 5f9a773

Please sign in to comment.