Skip to content

Instantly share code, notes, and snippets.

View drenther's full-sized avatar
🏠
Working from home

Soumyajit Pathak drenther

🏠
Working from home
View GitHub Profile
@drenther
drenther / Main.js
Created June 24, 2018 18:52
Main.js of the style-components-tutorial
import styled from 'styled-components';
const Main = styled.div`
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: flex-start;
justify-content: center;
align-content: flex-start;
`;
@drenther
drenther / Loader.styled-as-function.js
Last active June 25, 2018 08:15
Usage of styled as a function
/* src/components/Loader.js */
.
.
.
/* line 6 */
const Loader = ({ className }) => (<div className={className}><Loading/></div>)
@drenther
drenther / Loader.keyframes-and-pseudo-elements.js
Last active June 25, 2018 08:17
keyframes and pseudo-elements usage in styled-components
/* src/components/Loader.js */
/* line 1 - 39 */
import React from 'react';
import styled, { keyframes } from 'styled-components';
import { getColor } from '../utils/theme'
@drenther
drenther / User.pseudo-selector.js
Last active June 24, 2018 20:46
pseudo-selector usage in styled-components
/* src/User.js */
.
.
.
/* line 40 - 57 */
export default styled(User)`
width: 280px;
@drenther
drenther / Button.js
Last active June 25, 2018 08:16
Leveraging the power of props and css helper in styled-components
/* src/components/Button.js */
import styled, { css } from 'styled-components';
import { getFontSize, getColor } from '../utils/theme';
const Button = styled.button`
font-size: ${getFontSize('smFont')};
color: ${getColor('primary')};
background: ${getColor('light')};
@drenther
drenther / UserProfile.extend.js
Last active June 25, 2018 08:14
extending styles in styled-components
/* src/components/UserProfile.js */
.
.
.
/* line 74 - 83 */
const Value = styled.span`
font-size: ${getFontSize('tn')};
@drenther
drenther / UserProfile.js
Last active June 25, 2018 08:12
Media queries in styled-components
/* src/components/UserProfile.js */
.
.
.
/* line 44 */
const breakPoint = '600px';
@drenther
drenther / index.global-styles.js
Last active June 25, 2018 08:14
Global styling using injectGlobal from styled-components
/* src/index.js */
.
.
.
/* line 10 - 32 */
injectGlobal`
* {
@drenther
drenther / App.js
Created June 25, 2018 17:13
Theming in styled-components
/* src/App.js */
import styled, { ThemeProvider } from 'styled-components';
.
.
.
import { getUsers } from './utils/apiCalls';
import { invertTheme, getColor } from './utils/theme';
@drenther
drenther / Constructor.js
Last active April 26, 2023 16:16
Creational Pattern - Constructor
// traditional Function-based syntax
function Hero(name, specialAbility) {
// setting property values
this.name = name;
this.specialAbility = specialAbility;
// declaring a method on the object
this.getDetails = function() {
return this.name + ' can ' + this.specialAbility;
};