Browse Source

Add types to the styles

Alexander 3 years ago
parent
commit
5205a212cf

+ 3 - 3
kafka-ui-react-app/src/components/common/Button/Button.styled.ts

@@ -1,12 +1,12 @@
-import styled from 'styled-components';
+import { styled } from 'lib/themedStyles';
 
 
-export interface Props {
+export interface ButtonProps {
   buttonType: 'primary' | 'secondary';
   buttonType: 'primary' | 'secondary';
   buttonSize: 'S' | 'M' | 'L';
   buttonSize: 'S' | 'M' | 'L';
   isInverted?: boolean;
   isInverted?: boolean;
 }
 }
 
 
-const StyledButton = styled('button')<Props>`
+const StyledButton = styled('button')<ButtonProps>`
   display: flex;
   display: flex;
   flex-direction: row;
   flex-direction: row;
   align-items: center;
   align-items: center;

+ 1 - 2
kafka-ui-react-app/src/components/common/Button/Button.tsx

@@ -1,11 +1,10 @@
 import StyledButton, {
 import StyledButton, {
-  Props as ButtonProps,
+  ButtonProps,
 } from 'components/common/Button/Button.styled';
 } from 'components/common/Button/Button.styled';
 import React from 'react';
 import React from 'react';
 
 
 type Props = ButtonProps;
 type Props = ButtonProps;
 
 
 export const Button: React.FC<Props> = (props) => {
 export const Button: React.FC<Props> = (props) => {
-  // Later we can add other logic here
   return <StyledButton {...props} />;
   return <StyledButton {...props} />;
 };
 };

+ 10 - 0
kafka-ui-react-app/src/lib/themedStyles.ts

@@ -0,0 +1,10 @@
+import baseStyled, {
+  useTheme as baseUseTheme,
+  ThemedStyledInterface,
+} from 'styled-components';
+import theme from 'theme/theme';
+
+type ThemeInterface = typeof theme;
+
+export const styled = baseStyled as ThemedStyledInterface<ThemeInterface>;
+export const useTheme = () => baseUseTheme() as ThemeInterface;