File tree Expand file tree Collapse file tree 4 files changed +45
-8
lines changed Expand file tree Collapse file tree 4 files changed +45
-8
lines changed Original file line number Diff line number Diff line change
1
+ @import " ../theme/colors.scss" ;
2
+
3
+ .button {
4
+ background : $theme-link-color ;
5
+ position : relative ;
6
+ padding : 8px 20px ;
7
+ border-top : 0px ;
8
+ border-left : 0px ;
9
+ border-right : 0px ;
10
+ border-bottom : 6px solid $theme-link-color-dark ;
11
+ color : white ;
12
+ font-size : 16px ;
13
+ font-family : Lucida Sans Unicode , sans-serif ;
14
+ vertical-align : middle ;
15
+ -webkit-border-radius : 6px ;
16
+ -moz-border-radius : 6px ;
17
+ border-radius : 6px ;
18
+ -webkit-box-shadow : 0px 1px 6px 1px #999999 ;
19
+ box-shadow : 0px 1px 6px 1px #999999 ;
20
+ transition : all 0.1s ;
21
+ & :hover {
22
+ top : -1px ;
23
+ border-bottom : 7px solid $theme-link-color-dark ;
24
+ background : $theme-link-color ;
25
+ }
26
+ & :active {
27
+ top : 2px ;
28
+ border-bottom : 4px solid $theme-link-color-dark ;
29
+ background : $theme-link-color-dark ;
30
+ -webkit-box-shadow : none ;
31
+ box-shadow : none ;
32
+ }
33
+ }
Original file line number Diff line number Diff line change 1
1
import React from "react" ;
2
+ import styles from "./Button.module.scss" ;
2
3
3
4
// Define an interface for the props of the button component
4
5
interface ButtonProps {
5
- text : string ; // The text to display on the button
6
6
onClick : ( ) => void ; // The handler function for the click event
7
7
disabled ?: boolean ; // An optional prop to disable the button
8
+ children : React . ReactNode ;
8
9
}
9
10
10
11
// Define a custom button component that renders a button element
11
- const Button : React . FC < ButtonProps > = ( { text , onClick, disabled } ) => {
12
+ const Button : React . FC < ButtonProps > = ( { onClick, disabled, children } ) => {
12
13
// Return the JSX element for the button component
13
14
return (
14
- < button onClick = { onClick } disabled = { disabled } >
15
- { text }
15
+ < button className = { styles . button } onClick = { onClick } disabled = { disabled } >
16
+ { children }
16
17
</ button >
17
18
) ;
18
19
} ;
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import React, { useState } from "react";
2
2
import { useDispatch , useSelector } from "react-redux" ;
3
3
import { RootState } from "../../app/rootReducer" ;
4
4
import { increment , decrement , incrementByAmount } from "./counterSlice" ;
5
+ import Button from "../../components/Button" ;
5
6
6
7
// Define a counter component that uses the redux state and actions
7
8
const Counter : React . FC = ( ) => {
@@ -48,10 +49,10 @@ const Counter: React.FC = () => {
48
49
< div >
49
50
< h1 > Counter</ h1 >
50
51
< p > The current counter value is { counter } </ p >
51
- < button onClick = { handleIncrement } > Increment</ button >
52
- < button onClick = { handleDecrement } > Decrement</ button >
52
+ < Button onClick = { handleIncrement } > Increment</ Button >
53
+ < Button onClick = { handleDecrement } > Decrement</ Button >
53
54
< input value = { incrementAmount } onChange = { handleIncrementAmountChange } />
54
- < button onClick = { handleIncrementByAmount } > Increment by amount</ button >
55
+ < Button onClick = { handleIncrementByAmount } > Increment by amount</ Button >
55
56
</ div >
56
57
) ;
57
58
} ;
Original file line number Diff line number Diff line change 1
- $theme-link-color : #ff5733 ;
1
+ $theme-link-color : #ff5733 ;
2
+ $theme-link-color-dark : #fe3e13 ;
3
+ $white : #ffffff ;
You can’t perform that action at this time.
0 commit comments