Skip to content

Commit

Permalink
🚧 Extending Styles
Browse files Browse the repository at this point in the history
Extending Styles
  • Loading branch information
SaishJ committed Oct 2, 2022
1 parent 43ad56c commit 6c74b72
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## React Styled Component
## React Styled Component 💅

1. [Basic Styled Component](https://github.com/SaishJ/React-Styled-Components/commit/5488492b54661fec964a4202f9a1a79461b8534e)

2. [Using Props](https://github.com/SaishJ/React-Styled-Components/commit/43ad56cf0bf7906c39d9494c8d0fe2ce2bcae9d3)
7 changes: 6 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "./App.css";
// import styled from "styled-components";
import StyledButton from "./component/Button";
import StyledButton, { FancyButton } from "./component/Button";

// const StyledButton = styled.button`
// border: 2px solid #4caf50;
Expand All @@ -24,6 +24,11 @@ function App() {
<br />
</div>
<StyledButton variant="outline">Styled Button</StyledButton>
<div>
<br />
</div>
<FancyButton as="a">Fancy Button</FancyButton>
{/* as - is a polymorphic prop => pass anchor tag */}
</div>
);
}
Expand Down
17 changes: 2 additions & 15 deletions src/component/Button.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
import styled from "styled-components";

const StyledButton = styled.button`
border: 2px solid #4caf50;
background-color: ${(props) =>
props.variant === "outline" ? "#fff" : "#4caf50"};
color: ${(props) => (props.variant === "outline" ? "#4caf50" : "#fff")};
padding: 15px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 12px;
cursor: pointer;
transition: 0.5s all ease-out;
`;
import { StyledButton, FancyButton } from "./Button.styles";

export default StyledButton;
export { FancyButton };
20 changes: 20 additions & 0 deletions src/component/Button.styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import styled from "styled-components";

export const StyledButton = styled.button`
border: 2px solid #4caf50;
background-color: ${(props) =>
props.variant === "outline" ? "#fff" : "#4caf50"};
color: ${(props) => (props.variant === "outline" ? "#4caf50" : "#fff")};
padding: 15px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 12px;
cursor: pointer;
transition: 0.5s all ease-out;
`;

export const FancyButton = styled(StyledButton)`
background-image: linear-gradient(to right, #f6d365 0%, #fda085 100%);
border: none;
`;

0 comments on commit 6c74b72

Please sign in to comment.