Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use theming instead of custom background prop #141

Merged
merged 1 commit into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
);