Skip to content

Instantly share code, notes, and snippets.

View usulpro's full-sized avatar
🟢

Oleg Proskurin usulpro

🟢
View GitHub Profile
@usulpro
usulpro / Multistories.md
Last active July 7, 2017 15:31
Multistories

Multistories mode

storyKindName argument passing to storiesOf may contain symbols to indicate multistory sections.

Multistories mode unlike singlestory displays all stories of the section at preview area. It doesn't affect how it appears at the Stories panel.

Default separator: :.

Example:

@usulpro
usulpro / options.md
Last active July 7, 2017 22:26
Passing options to storiesOf

I want to continue the discussion started in storybookjs/storybook#1394 (comment)

Here are some thoughts that I have about this new API for storiesOf. I offer to use them as a starting point for this work, sure this is far from being a complete list of issues. So any ideas are very welcome!

1 storiesOf('storyKindName', { options }) vs storiesOf('storyKindName', module).setOptions()

At first glance, no big difference, but:

1.1 .setOptions() more relevant to the idea of local/global options

input CreatePost {
imageUrl: String!
title: String!
}
type Mutation {
createPost(imageUrl: String!, title: String!): Post
updatePost(id: ID!, imageUrl: String, title: String): Post
updateOrCreatePost(update: UpdatePost!, create: CreatePost!): Post
deletePost(id: ID!): Post
@usulpro
usulpro / maps.md
Last active August 13, 2018 15:04
Maps

Для отображения на карте маркеров нужно получить массив данных, содержащий:

  1. координаты маркера ввиде {lat: -25.344, lng: 131.036}
  2. сопутствующие данные

варианты (у платных есть ссылка на pricing):

OpenStreetMap

docs

$ yarn add contentful @contentful/rich-text-react-renderer @contentful/rich-text-types
// lib/contentful-client.js
const { createClient } = require("contentful");
const { SPACE, DELIVERY_TOKEN, PREVIEW_TOKEN } = require("./contentful-config");
// const { getLocalMocks } = require('./getLocalMocks');
const isProduction = process.env.NODE_ENV === "production";
// const isLocalMocks = !!process.env.LOCAL;
// pages/leaders.js
import React from "react";
import { getPage } from "../lib/getPage";
import renderTemplate from "../lib/renderTemplate";
import Layout from "../components/Layout";
const entryId = "7iaB95RCl0IH3Z73ON1hBq";
// lib/getPage.js
import { getEntry } from "./contentful-client";
import { selectImages, selectTemplate } from "./cms-selectors";
export const getPage = async entryId => {
const customPage = await getEntry(entryId);
const {
url,
// lib/renderTemplate.js
import { renderComponents } from "./renderNestedComponents";
const templateTypes = {
standard: "templateStandard",
};
const renderTemplate = ({ templateType, data }, options) => {
if (templateType === templateTypes.standard) {
// lib/renderNestedComponents.js
import React from "react";
import { componentsMap } from "./componentsMap";
import {
selectComponentReference,
selectComponentProps,
selectEntryId,
} from "./cms-selectors";