Skip to content

Commit

Permalink
feat: add spacing component margin and text
Browse files Browse the repository at this point in the history
  • Loading branch information
ilkyazarabaci committed Oct 8, 2023
1 parent 7e06769 commit 66b30e9
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 9 deletions.
6 changes: 4 additions & 2 deletions packages/react/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ export default {
input: [
'src/index.ts',
// 'src/atoms/Button/index.ts',
'src/atoms/Color/index.ts'
'src/atoms/Color/index.ts',
'src/atoms/Margin/index.ts',
'src/atoms/Text/index.ts'
],
output: {
dir: 'lib',
Expand All @@ -13,5 +15,5 @@ export default {
},
plugins: [Ts()],
preserveModules: true,
external: ['react']
external: ['react', '@ds.e/foundation']
}
41 changes: 41 additions & 0 deletions packages/react/src/atoms/Margin/Margin.tsx
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;
1 change: 1 addition & 0 deletions packages/react/src/atoms/Margin/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./Margin";
15 changes: 15 additions & 0 deletions packages/react/src/atoms/Text/Text.tsx
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;
1 change: 1 addition & 0 deletions packages/react/src/atoms/Text/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./Text";
6 changes: 4 additions & 2 deletions packages/react/src/index.ts
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 };
15 changes: 15 additions & 0 deletions packages/scss/src/atoms/Margin.scss
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;
}
}
}
11 changes: 11 additions & 0 deletions packages/scss/src/atoms/Text.scss
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;
}
}
17 changes: 12 additions & 5 deletions playgrounds/react/src/index.tsx
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>,
)

0 comments on commit 66b30e9

Please sign in to comment.