Skip to content

Commit

Permalink
fix: contextual component (#141)
Browse files Browse the repository at this point in the history
- Use theming instead of custom background prop
- Remove backgroundcolor prop from Contextual styles
- Fix hover flickering errors
- Remove styles provider
  • Loading branch information
amalv committed Dec 17, 2019
1 parent e42beb8 commit ae50d4d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 37 deletions.
4 changes: 0 additions & 4 deletions src/MuiTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ const theme = createMuiTheme({
background: {
default: "#fff",
},
text: {
primary: "#7f39fb",
secondary: "rgba(0, 0, 0, 0.74)",
},
},
overrides: {
MuiMenuItem: {
Expand Down
10 changes: 1 addition & 9 deletions src/components/Contextual.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,11 @@ export interface BackgroundImageProps {
image: string;
}

interface ContextualButtonProps {
textcolor?: string | undefined;
backgroundcolor?: string | undefined;
}

export const ContextualContainer = styled.div`
position: relative;
`;

export const ContextualButton = styled(Button)<ContextualButtonProps>`
height: 36px;
background-color: ${({ backgroundcolor }): string => backgroundcolor || "white"};
color: ${({ textcolor }): string => textcolor || "white"};
export const ContextualButton = styled(Button)`
top: 140%;
left: 50%;
margin-right: -50%;
Expand Down
45 changes: 21 additions & 24 deletions src/components/Contextual.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";
import Grid from "@material-ui/core/Grid";
import { ThemeProvider, StylesProvider } from "@material-ui/core/styles";
import { StylesProvider } from "@material-ui/core/styles";
import {
BackgroundImage,
Title,
Expand All @@ -11,7 +11,6 @@ import {
Body,
ContextualButton,
} from "./Contextual.styles";
import theme from "../MuiTheme";

export interface ContextualProps {
name: string;
Expand All @@ -29,27 +28,25 @@ export const Contextual: React.FC<ContextualProps> = ({
button,
}: ContextualProps) => (
<StylesProvider injectFirst>
<ThemeProvider theme={theme}>
<ContextualContainer>
<StyledGrid container direction="column" spacing={1}>
<Grid item>
<Name>{name}</Name>
</Grid>
<Grid item>
<Title>{title}</Title>
</Grid>
<Grid item>
<Body>{body}</Body>
</Grid>
</StyledGrid>
<BackgroundImage image={image} />
<Overlay />
{button ? (
<ContextualButton backgroundcolor={theme.palette.primary.main}>
Start a topic
</ContextualButton>
) : null}
</ContextualContainer>
</ThemeProvider>
<ContextualContainer>
<StyledGrid container direction="column" spacing={1}>
<Grid item>
<Name>{name}</Name>
</Grid>
<Grid item>
<Title>{title}</Title>
</Grid>
<Grid item>
<Body>{body}</Body>
</Grid>
</StyledGrid>
<BackgroundImage image={image} />
<Overlay />
{button ? (
<ContextualButton variant="contained" color="primary">
Start a topic
</ContextualButton>
) : null}
</ContextualContainer>
</StylesProvider>
);

1 comment on commit ae50d4d

@vercel
Copy link

@vercel vercel bot commented on ae50d4d Dec 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.