Skip to content

Instantly share code, notes, and snippets.

View awinogradov's full-sized avatar
:octocat:
Coding happiness

Tony Vi awinogradov

:octocat:
Coding happiness
View GitHub Profile
@awinogradov
awinogradov / index.jsx
Created August 15, 2018 17:56
Bem Composition
import React from 'react';
import styled from "styled-components";
import { bemClassName } from 'bem-react-core';
import { react } from '@bem/sdk.naming.presets';
import logo from './logo.svg';
import './App.css';
const bemed = (block, mods) => (elemPure) => {
const naming = bemClassName(react);
@awinogradov
awinogradov / Select.tsx
Last active June 19, 2018 14:47
BRC deps
import Button from '../Button';
import Icon from '../Icon';
class CSelect {
public dependencies() {
return {
Icon,
Button
}
}
export function compose<T0, T1 extends T0, T2 extends T0>(a: T0, b:T1, c: T2): T1 & T2;
export function compose<T0, T1>(a: T0, b:T1): T0 & T1;
@awinogradov
awinogradov / index.js
Created April 4, 2018 09:26
BEM Compose
class Bem {
}
// src/common/Block/Block.js
class Block extends Bem {
constructor() {
super();
this.a = 1;
}
@awinogradov
awinogradov / index.js
Last active September 30, 2023 03:14
Classes
class Bem {
}
// src/common/Block/Block.js
class Block extends Bem {
constructor() {
super();
this.a = 1;
}
@awinogradov
awinogradov / index.ts
Last active April 3, 2018 17:16
Takie dela
function combineClasses<T1, T2>(C1, C2): new (...args: any[]) => T1 & T2 {
Object.getOwnPropertyNames(C2.prototype).forEach((name) => {
if (name !== 'constructor') {
C1.prototype[name] = C2.prototype[name];
}
});
return Object.setPrototypeOf(C2, C1);
}
function compose<T>(...args: Array<new (...args: any[]) => T>): new (...args: any[]) => T {
export default class Stars extends Component {
async componentDidMount() {
let stars = await githubStars(this.props.repo);
this.setState({ stars });
}
render({ repo }, { stars=0 }) {
let url = `//github.com/${repo}`;
return (
<a href={url} class="stars">
⭐️ {stars} Stars
@awinogradov
awinogradov / Header-Inner.js
Last active December 15, 2017 15:06
bem-react-core
import { decl } from 'bem-react-core'
export default decl({
block: 'Header',
elem: 'Inner',
attrs({ id }) {
return { id }
}
})
@awinogradov
awinogradov / example.js
Created May 7, 2017 00:36
easy-breezy API for @bem/naming
const naming = require('./pretty-naming');
const b1 = p('block').m({ m1: 1, m2: 2 });
const b2 = p('block42').m({ m3: 3 });
b1.mix(b2);
console.log(b1.stringify());
// 'block_m1_1 block_m2_2 block42_m3_3'
@awinogradov
awinogradov / README.md
Last active January 31, 2017 18:14
Connect to state (bem-react-core)
  • blocks
    • Screen
      • Actions
        • Screen-Actions.js
      • Reducer
        • Screen-Reducer.js
      • Screen.js
    • Root
      • Root.js
  • state