Skip to content

Commit

Permalink
feat: add props in VisitorCounter components
Browse files Browse the repository at this point in the history
add props in VisitorCounter components"#164"
  • Loading branch information
seohyunsim committed Oct 3, 2022
1 parent a580995 commit a32557e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function App() {
<Channel />
<Channels />

<VisitorCounter />
<VisitorCounter titleColor="red" />
<VisitorComment
id="['VisitorComment', 'akar-icons:comment-add']"
inputBackgroundColor="red"
Expand Down
6 changes: 6 additions & 0 deletions src/lib/common/types/ComponentTypes/VisitorCounterType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export interface VisitorCounterPropsType {
* Color of total visit count used in 'big-size' and 'simple' (default: red)
*/
totalBoldColor?: string;
titleColor?: string;
todayTitleColor?: string;
totalTitleColor?: string;
}

export interface IndexPropsType extends VisitorCounterPropsType {
Expand Down Expand Up @@ -63,4 +66,7 @@ export interface VisitorCounterStylePropsType {
* Color of total visit count used in 'big-size' and 'simple' (default: red)
*/
totalBoldColor?: string;
titleColor?: string;
todayTitleColor?: string;
totalTitleColor?: string;
}
12 changes: 9 additions & 3 deletions src/lib/components/VisitorCounter/BigSize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ export const BigSize = (props: VisitorCounterPropsType) => {
size,
todayBoldColor,
totalBoldColor,
titleColor,
todayTitleColor,
totalTitleColor,
} = props;

return (
<Wrap backgroundColor={backgroundColor} size={size}>
<Wrap backgroundColor={backgroundColor} size={size} titleColor={titleColor}>
<span className="title">{title}</span>
<Today todayBoldColor={todayBoldColor}>
<Today todayBoldColor={todayBoldColor} todayTitleColor={todayTitleColor}>
<span className="today">{todayTitle}</span>
<span className="today-visitor">{todayVisitor}</span>
</Today>
<Total totalBoldColor={totalBoldColor}>
<Total totalBoldColor={totalBoldColor} totalTitleColor={totalTitleColor}>
<span className="total">{totalTitle}</span>
<span className="total-visitor">{totalVisitor}</span>
</Total>
Expand All @@ -46,6 +49,7 @@ const Wrap = styled.div<VisitorCounterStylePropsType>`
padding: 10px;
flex-grow: 1;
font-weight: bold;
color: ${({ titleColor }) => titleColor ?? 'black'};
}
`;

Expand All @@ -54,6 +58,7 @@ const Today = styled.div<VisitorCounterStylePropsType>`
padding: 10px;
.today {
margin-right: 5em;
color: ${({ todayTitleColor }) => todayTitleColor ?? 'black'};
}
.today-visitor {
font-weight: bold;
Expand All @@ -66,6 +71,7 @@ const Total = styled.div<VisitorCounterStylePropsType>`
padding: 10px;
.total {
margin-right: 5em;
color: ${({ totalTitleColor }) => totalTitleColor ?? 'black'};
}
.total-visitor {
font-weight: bold;
Expand Down
6 changes: 4 additions & 2 deletions src/lib/components/VisitorCounter/Default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {
} from '../../common/types/ComponentTypes/VisitorCounterType';

const Default = (props: VisitorCounterPropsType) => {
const { title, todayVisitor, totalVisitor, backgroundColor, size } = props;
const { title, todayVisitor, totalVisitor, backgroundColor, size, titleColor } = props;

return (
<Wrap size={size}>
<Counter backgroundColor={backgroundColor}>
<Counter backgroundColor={backgroundColor} titleColor={titleColor}>
<span className="title">{title}</span>
<span className="today">{todayVisitor}</span>
<span className="total">{totalVisitor}</span>
Expand All @@ -35,8 +35,10 @@ const Counter = styled.div<VisitorCounterStylePropsType>`
border: 1px solid #989898;
border-radius: 5px;
overflow: hidden;
background-color: white;
.title {
background-color: ${({ backgroundColor }) => backgroundColor ?? '#91c230c4'};
color: ${({ titleColor }) => titleColor ?? 'black'};
}
.today {
border-left: 1px solid #989898;
Expand Down
26 changes: 24 additions & 2 deletions src/lib/components/VisitorCounter/Simple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,26 @@ import {
} from '../../common/types/ComponentTypes/VisitorCounterType';

export const Simple = (props: VisitorCounterPropsType) => {
const { todayTitle, todayVisitor, totalTitle, totalVisitor, size, todayBoldColor, totalBoldColor } = props;
const {
todayTitle,
todayVisitor,
totalTitle,
totalVisitor,
size,
todayBoldColor,
totalBoldColor,
todayTitleColor,
totalTitleColor,
} = props;

return (
<Wrap size={size} todayBoldColor={todayBoldColor} totalBoldColor={totalBoldColor}>
<Wrap
size={size}
todayBoldColor={todayBoldColor}
totalBoldColor={totalBoldColor}
todayTitleColor={todayTitleColor}
totalTitleColor={totalTitleColor}
>
<span className="today">{todayTitle}</span>
<span className="today-visitor">{todayVisitor}</span>
<span className="total">{totalTitle}</span>
Expand All @@ -23,6 +39,9 @@ const Wrap = styled.div<VisitorCounterStylePropsType>`
span {
padding: 3px;
}
.today {
color: ${({ todayTitleColor }) => todayTitleColor ?? 'black'};
}
.today-visitor {
font-weight: bold;
color: ${({ todayBoldColor }) => todayBoldColor ?? 'red'};
Expand All @@ -33,6 +52,9 @@ const Wrap = styled.div<VisitorCounterStylePropsType>`
color: black;
}
}
.total {
color: ${({ totalTitleColor }) => totalTitleColor ?? 'black'};
}
.total-visitor {
font-weight: bold;
color: ${({ totalBoldColor }) => totalBoldColor ?? 'black'};
Expand Down

0 comments on commit a32557e

Please sign in to comment.