-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add spacing component margin and text
- Loading branch information
ilkyazarabaci
committed
Oct 8, 2023
1 parent
7e06769
commit 66b30e9
Showing
9 changed files
with
104 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react' | ||
import { Spacing } from '@ds.e/foundation' | ||
|
||
export interface MarginProps { | ||
space?: keyof typeof Spacing | ||
left?: boolean, | ||
right?: boolean, | ||
top?: boolean, | ||
bottom?: boolean, | ||
children: React.ReactNode, | ||
} | ||
|
||
const Margin: React.FC<MarginProps> = ({ space = 'xxxs', children, left, right, top, bottom }) => { | ||
let className = `` | ||
|
||
if (!left && !right && !top && !bottom) { | ||
className = `dse-margin-${space}` | ||
} | ||
|
||
if (left) { | ||
className = `${className} dse-margin-left-${space}` | ||
} | ||
|
||
if (right) { | ||
className = `${className} dse-margin-right-${space}` | ||
} | ||
|
||
if (top) { | ||
className = `${className} dse-margin-top-${space}` | ||
} | ||
|
||
if (bottom) { | ||
className = `${className} dse-margin-bottom-${space}` | ||
} | ||
|
||
return <div className={className}> | ||
{children} | ||
</div> | ||
} | ||
|
||
export default Margin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "./Margin"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react' | ||
import { FontSize } from '@ds.e/foundation' | ||
|
||
export interface TextProps { | ||
size?: keyof typeof FontSize, | ||
children: React.ReactNode, | ||
} | ||
|
||
const Text: React.FC<TextProps> = ({ size = FontSize.base, children }) => { | ||
const className = `dse-text dse-text-${size}` | ||
|
||
return <p className={className}>{children}</p> | ||
} | ||
|
||
export default Text; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "./Text"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
// import Button from "./atoms/Button"; | ||
import Button from "./atoms/Button"; | ||
import Color from "./atoms/Color"; | ||
import Text from "./atoms/Text"; | ||
import Margin from "./atoms/Margin"; | ||
|
||
export { Color }; | ||
export { Button, Color, Text, Margin }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@import "foundation/all"; | ||
|
||
$sides: left, right, top, bottom; | ||
|
||
@each $space, $value in $spacing { | ||
.dse-margin-#{$space} { | ||
margin: $value; | ||
} | ||
|
||
@each $side in $sides { | ||
.dse-margin-#{$side}-#{$space} { | ||
margin-#{$side}: $value; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@import "foundation/all"; | ||
|
||
.dse-text { | ||
margin: 0; | ||
} | ||
|
||
@each $size, $value in $fs { | ||
.dse-text-#{$size} { | ||
font-size: $value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom/client"; | ||
|
||
// import Button from '@ds.e/react'; | ||
import Color from '@ds.e/react'; | ||
// import '@ds.e/scss/lib/Button.css'; | ||
import { Color, Margin, Text, Button } from '@ds.e/react'; | ||
|
||
import '@ds.e/scss/lib/Button.css'; | ||
import '@ds.e/scss/lib/Utilities.css'; | ||
import '@ds.e/scss/lib/Text.css'; | ||
import '@ds.e/scss/lib/Margin.css'; | ||
|
||
const root = ReactDOM.createRoot( | ||
document.getElementById('root') as HTMLElement | ||
) | ||
|
||
root.render( | ||
<React.StrictMode> | ||
<Color hexCode='#000' /> | ||
{/* <Button label="React Playground"/> */} | ||
<div> | ||
<Color hexCode='#000' width="lg" height="lg"/> | ||
<Margin top bottom space='md'> | ||
<Text size='xs'>This is some text.</Text> | ||
</Margin> | ||
<Button label="React Playground"/> | ||
</div> | ||
</React.StrictMode>, | ||
) |