HNHacker News
TopNewBestAskShowJobs

andreypopp

1,040 karma · joined June 30, 2011

just sitting there, looking shiny...

https://github.com/andreypopp https://twitter.com/andreypopp

submissionscomments
andreypopp··on Show HN: Styled-components – Use the best of ES6 to style React apps
I think using strings as an API is a step in the wrong direction. I like that it produces a React component directly though.

We experimented with styling approaches for React a while ago and produced our solution — React Stylesheet[1], which we used for over an year in different React applications.

It also produces components out of style definitions directly:

    let GreenBox = style('div', {
      base: {
        background: 'green'
      }
    })
Which you can use like any other React component later:

    <GreenBox />
As you can see the API is kinda similar but uses JS instead of CSS string. What are advantages? The following:

* Consistent syntax: you can use functions, variabls, mixins, w/o the need for interpolation `${...}`.

* Tooling. This is big one. You can make your stylesheets linted with ESLint and typesafe (!!!) with FlowType or TypeScript.

FlowType is supported out of the box, see [2]. Typesafe stylesheets is a huge win for productivity, I constantly catch typos and invalid values via Flow.

[1]: https://github.com/prometheusresearch/react-stylesheet/blob/... [2]: https://github.com/prometheusresearch/react-stylesheet/blob/...

EDIT: additions

Styles are compiled into CSS so :hover and friends work here.

andreypopp··on Gatsby – A Static Site Generator for React
Another one which is also based on React I've been working on recently: http://andreypopp.github.io/sitegen/

Supports pagination and progressive content loading, I believe its design is superior to other React based static site generators.

andreypopp··on TypeScript and JSX
You can also use regular JS control flow within JSX. That's the point.
andreypopp··on CSS Modules
Webpack's css-loader implements CSS modules specificaton, see https://github.com/webpack/css-loader#css-modules
andreypopp··on CSS Modules
We started to migrate away from pure CSS Modules to Styling in our apps. Code didn't hit production yet but we are close.

Writing styles in JS instead of CSS gave us a huge expressiveness boost and allowed to use existing JS tooling such as eslint. At the same time all CSS tooling still can be applied to compilation result (such as autoprefixer).

Also would be fun to write styles in TypeScript — statically typed styles sounds great.

andreypopp··on CSS Modules
That (extraction) can be done (React Style does that) but for it to be consistent with JS semantics you need to evaluate code at build time because such template strings can contain interpolations from JS world.
andreypopp··on CSS Modules
Also see styling[0] which is a loader for webpack which allows to generate CSS modules with JS.

Files configured to use with this loader (usually `.style.js`) are executed at build time and produce CSS modules. You can use any JS abstractions for that (functions, modules, variables, ...) and any npm package available (color manipulation, typography, ...):

  import styling from 'styling'
  import {smallText} from './typography'
  import {colors} from './theme'

  export let caption = styling({
    ...smallText,
    color: colors.text
  })
[0]: https://github.com/andreypopp/styling
andreypopp··on Is ReactJS really fast?
> - JSX breaks your IDE's error checking and line numbers in error messages (and not using JSX is a pain/verbose)

JSX doesn't break line numbers in error messages because JSX to JS transform preserves line numbers.

andreypopp··on Messenger.com
And it's built with React.js!
andreypopp··on HippyVM goes to Y Combinator and fails
They building infrastructure (lang, community, lib ecosystem, stack) on top of another infrastructure. I think that's ok.
andreypopp··on Microsoft is killing off the Internet Explorer brand
Also try using apps which use flexbox intensively — FF triggers exponential slowdown when handling deeply nested flexbox layouts[0]...

[0]: https://github.com/philipwalton/flexbugs/issues/8

andreypopp··on React v0.13 released
> what they're actually saying is, React is getting even faster while other frameworks try are playing catch-up.

Isn't that true?

andreypopp··on Show HN: React-hn – Supports all Hacker News API v0 item types
I've added a paragraph to the README. Basically UI lifecycle and data flow should be decoupled. React component's state (which is used by React Async to store data) is for UI state and not for data.
andreypopp··on Show HN: React-hn – Supports all Hacker News API v0 item types
Uhm... no, I don't think react-async is a good way to manage data flow in React applications. I wrote it when I started to work with React but now I consider React Async an anti-pattern.
andreypopp··on A React.js case study
https://github.com/facebook/jstransform/tree/master/visitors
andreypopp··on Ur/web: pure functional, statically typed web programming
You could also be interested in PureScript[1] then; and its React bindings[2]. It is a statically typed language which compiles to JS. It has row polymorphism and effects (yay!).

[1]: http://purescript.org [2]: https://github.com/purescript-contrib/purescript-react

andreypopp··on Tidal Lock: optional static type checking and inference for Lua
I'd also add to this that PureScript[1] is soon to have a Lua backend[2]. PureScript is a statically typed language with row polymorphic types, algebraic effects and type inference.

[1]: http://purescript.org [2]: https://github.com/osa1/psc-lua

andreypopp··on Love Generating SVG With JavaScript? Move It To The Server
There's ReactART (https://github.com/facebook/react-art), React bindings to ART drawing library. It can render to SVG, VML or Canvas. Not sure thought how it can be used on server but I suppose it can be done.
andreypopp··on OCaml 4.02: Everything else
> I understand that OCaml isn't lazily evaluated like Haskell and has a simpler to understand compiler which gives a better understanding how the code will perform at runtime. But why as someone new why would I choose OCaml over Haskell?

Isn't that enough to choose OCaml over Haskell?

andreypopp··on React Forms: form rendering and validation for React
I want to highlight few points in the design of the library.

Responsibility is divided between form schemas, form components and input components:

* Form schema provides a high-level description of a form: what's shape of the data it handles, how to validate user input, what labels to render for each field and so on.

* Form components are React components which interpret form schemas to build UI and setup dataflow between different parts of the form.

* Input components handle user input, they should adhere to "value/onChange" contract and so are reusable outside of React Forms context.

We tried to make every aspect of React Forms to be extendable and replaceable: form schemas can hold additional metadata, custom form and input components can be created. There's a documentation page (http://prometheusresearch.github.io/react-forms/documentatio...) which tries to put the light on how to extend/customize React Forms components.

All of the form components except of the top level Form component are stateless. Form state (value and validation state) is propagated to form fields as lenses to the entire form state. On user input a corresponding form field produces a new form value and validation state (via lenses, so this is opaque to the form field itself) and notifies top level form component.

Form state is immutable (on each change a new value is produced) and so such functionality as undo/redo can be implemented easily. See the example (http://prometheusresearch.github.io/react-forms/examples/und...) which implements basic undo/redo in about 40LOC.

andreypopp··on ExpressJS 4.0 has been released
Who needs JIT on I/O bound tasks?
andreypopp··on Why Use Make? (2013)
I thought with make you also write scripts in shell.
andreypopp··on The Road to React 1.0
You could take a look at https://github.com/andreypopp/sweet-jsx which fences the JSX syntax inside tagged template literal.
andreypopp··on Arscoin, our own custom cryptocurrency
It's not about using separate block chains, it's about making cryptocoins non-fungible.
andreypopp··on Writing Your First Sweet.js Macro
If you already use build process, the additional step would be just one additional step in the build process, "invisible" to you. So "save in Vi, reload" still works.

If you don't have build process when writing JS code for browser, well... I don't know how it's possible.

I suggest you to look at browserify (http://browserify.org). For sweet.js there's sweetify (https://npmjs.org/package/sweetify) transform.

Note, that sweet.js compiler generates source maps, so you can debug your code with comfort.

Syntax highlighting still works, because most of the syntax highlighters highlight tokens and macros preserve token structure of the language (well it can kinda "introduce" keywords, but if you use Vi, it's just 1 line of code to fix your setup).

andreypopp··on Writing Your First Sweet.js Macro
I found sweet.js so much useful for scraping boilerplate out of my code. Example — sweet-assertions https://github.com/andreypopp/sweet-assertions — a set of macros to generate assertions with nice failure messages.

Edit: another experimental macros — https://github.com/andreypopp/react-macros — a set of syntax extensions for writing React (http://facebook.github.io/react) components.

andreypopp··on Demystifying AngularJS' dependency injection
I think this kind of things is much more suitable to be implemented via macros because 1) it can be implemented with much nicer syntax not abusing function syntax and 2) it can be done at compile time (I mean true compile time, not in browser).

Consider the following syntax:

    // values to inject
    var registry = {
      scope: ...
      http: ...
    }

    inject http, scope {
      http.get('/search', {query: scope.query}).then(render);
    }
all of these can be done today with sweet.js[1] — see the example http://bit.ly/1bjdxWJ

[1]: http://sweetjs.org

andreypopp··on Demystifying AngularJS' dependency injection
Here you go — http://bit.ly/1ic1X49
andreypopp··on The best todo list app for any developer
What if your todolist is too large? Store it somewhere else (in you homedir, no need for a sudo) and add

  head -n 10 ~/todo.md
to your .bashrc/.zshrc to show 10 most prioritised tasks on each session startup.
andreypopp··on CoffeeScript 1.7.0
You can get even nicer and more useful (due to generated assertion messages) with Sweet.js macros (https://github.com/andreypopp/sweet-assertions)

  describe 'when the universe exists' {
    it 'should be active' {
      universe.active should be true
    }
  }
The pre-generated assertion messages means you get `universe.active should be true` in case of error which includes actual source of the expression.
← PreviousPage 3 of 5Next →