Skip to content

Commit 8b379a0

Browse files
MichaelDeBoeyCompuIves
authored andcommitted
Fix typings (codesandbox#2693)
1 parent 15a0626 commit 8b379a0

File tree

4 files changed

+61
-74
lines changed

4 files changed

+61
-74
lines changed
Lines changed: 58 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,72 @@
1-
import React from 'react';
2-
import styled from 'styled-components';
3-
import { Link } from 'react-router-dom';
41
import delayEffect from '@codesandbox/common/lib/utils/animation/delay-effect';
2+
import React, { ComponentProps, forwardRef } from 'react';
3+
import { Link } from 'react-router-dom';
54
import { MenuSeparator } from 'reakit';
5+
import styled, { css } from 'styled-components';
66

77
export const Container = styled.div`
8-
background-color: ${props => props.theme.background4};
9-
box-shadow: 0px 3px 8px rgba(0, 0, 0, 0.75);
8+
${({ theme }) => css`
9+
background-color: ${theme.background4};
10+
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.75);
1011
11-
${delayEffect(0)};
12+
${delayEffect(0)};
1213
13-
min-width: 200px;
14+
min-width: 200px;
1415
15-
z-index: 20;
16+
z-index: 20;
17+
`};
1618
`;
1719

18-
const StyledMenu = styled(Link)<{ to?: string; href?: string }>`
19-
transition: 0.3s ease all;
20-
display: flex;
21-
align-items: center;
22-
font-size: 0.875rem;
23-
padding: 0.5rem 1rem;
20+
const StyledMenu = styled(Link)<{ href?: string; to?: string }>`
21+
${({ theme }) => css`
22+
transition: 0.3s ease all;
23+
display: flex;
24+
align-items: center;
25+
font-size: 0.875rem;
26+
padding: 0.5rem 1rem;
2427
25-
text-decoration: none;
28+
text-decoration: none;
2629
27-
color: rgba(255, 255, 255, 0.8);
28-
border: 0;
29-
outline: 0;
30-
outline-width: 0 !important;
31-
box-sizing: border-box;
32-
border-left: 2px solid transparent;
33-
background-color: transparent;
34-
width: 100%;
30+
color: rgba(255, 255, 255, 0.8);
31+
border: 0;
32+
outline: 0 !important;
33+
box-sizing: border-box;
34+
border-left: 2px solid transparent;
35+
background-color: transparent;
36+
width: 100%;
3537
36-
cursor: pointer;
38+
cursor: pointer;
3739
38-
&:focus {
39-
border-color: ${props => props.theme.secondary};
40-
color: white;
41-
background-color: ${props => props.theme.secondary.clearer(0.9)};
42-
outline: 0;
43-
}
40+
&:focus {
41+
border-color: ${theme.secondary};
42+
color: white;
43+
background-color: ${theme.secondary.clearer(0.9)};
44+
outline: 0;
45+
}
4446
45-
&:hover {
46-
border-color: ${props => props.theme.secondary};
47-
color: white;
48-
background-color: ${props => props.theme.secondary.clearer(0.9)};
49-
}
47+
&:hover {
48+
border-color: ${theme.secondary};
49+
color: white;
50+
background-color: ${theme.secondary.clearer(0.9)};
51+
}
52+
`};
5053
`;
5154

5255
const StyledMenuA = StyledMenu.withComponent('a');
5356
const StyledMenuButton = StyledMenu.withComponent('button');
5457

55-
export const ItemA = React.forwardRef((props: any, ref) => (
56-
<StyledMenuA {...props} ref={ref} />
57-
));
58-
export const ItemButton = React.forwardRef((props: any, ref) => (
59-
<StyledMenuButton {...props} ref={ref} />
60-
));
61-
export const ItemLink = React.forwardRef((props: any, ref) => (
62-
<StyledMenu {...props} innerRef={ref} />
63-
));
58+
export const ItemA = forwardRef<
59+
HTMLAnchorElement,
60+
ComponentProps<typeof StyledMenuA>
61+
>((props, ref) => <StyledMenuA {...props} ref={ref} />);
62+
export const ItemButton = forwardRef<
63+
HTMLButtonElement,
64+
ComponentProps<typeof StyledMenuButton>
65+
>((props, ref) => <StyledMenuButton {...props} ref={ref} />);
66+
export const ItemLink = forwardRef<
67+
HTMLAnchorElement,
68+
ComponentProps<typeof StyledMenu>
69+
>((props, ref) => <StyledMenu {...props} innerRef={ref} />);
6470

6571
export const Icon = styled.span`
6672
margin-right: 0.75rem;
@@ -69,11 +75,13 @@ export const Icon = styled.span`
6975
`;
7076

7177
export const Separator = styled(MenuSeparator)`
72-
height: 1px;
73-
width: 100%;
74-
margin: 0.5rem 0;
78+
${({ theme }) => css`
79+
height: 1px;
80+
width: 100%;
81+
margin: 0.5rem 0;
7582
76-
background-color: ${props => props.theme.background};
77-
border: 0;
78-
outline: 0;
83+
background-color: ${theme.background};
84+
border: 0;
85+
outline: 0;
86+
`};
7987
`;

packages/common/src/templates/icons.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,7 @@ import {
5858
TemplateType,
5959
} from '.';
6060

61-
export type ReturnedIcon = React.SFC<{
62-
width?: number;
63-
height?: number;
64-
className?: string;
65-
style?: React.CSSProperties;
66-
}>;
67-
68-
export default function getIcon(theme: TemplateType): ReturnedIcon {
61+
export default function getIcon(theme: TemplateType) {
6962
switch (theme) {
7063
case adonis.name:
7164
return AdonisIcon;

packages/common/src/templates/iconsDark.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,7 @@ import {
5858
TemplateType,
5959
} from '.';
6060

61-
export type ReturnedIcon = React.SFC<{
62-
width?: number;
63-
height?: number;
64-
className?: string;
65-
style?: React.CSSProperties;
66-
}>;
67-
68-
export default function getIcon(theme: TemplateType): ReturnedIcon {
61+
export default function getIcon(theme: TemplateType) {
6962
switch (theme) {
7063
case adonis.name:
7164
return AdonisIconDark;

packages/common/src/templates/iconsLight.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,7 @@ import {
5858
TemplateType,
5959
} from '.';
6060

61-
export type ReturnedIcon = React.SFC<{
62-
width?: number;
63-
height?: number;
64-
className?: string;
65-
style?: React.CSSProperties;
66-
}>;
67-
68-
export default function getIcon(theme: TemplateType): ReturnedIcon {
61+
export default function getIcon(theme: TemplateType) {
6962
switch (theme) {
7063
case adonis.name:
7164
return AdonisIconLight;

0 commit comments

Comments
 (0)