reactjs / reactjs/react-docgen

styled-components and Glamorous support

オープン
#256 コメント 6 件 リアクション 8 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
TypeScript
スター
3.8k
フォーク
316
平均マージ
5時間 7分
マージ済み PR(30日)
4

説明

Further to this discussion https://github.com/styleguidist/react-styleguidist/issues/37

If you are using styled-components, you may have a component similar to:

import styled, { css } from "styled-components";
import PropTypes from "prop-types";

const Button = styled.a`
  background: transparent;
  color: white;

  ${({primary}) =>
    !!primary &&
    css`
      background: white;
      color: palevioletred;
    `};
`;

Button.propTypes = {
  primary: PropTypes.bool
};

export default Button;

or, with Glamorous:

import glamorous from "glamorous";
import PropTypes from "prop-types";

const Button = glamorous.button({
  background: "transparent",
  color: "white"
},
  ({ primary }) => (!!primary && {
    background: "white",
    color: "palevioletred"
  })
);

Button.propTypes = {
  primary: PropTypes.bool
};

This doesn't import React, so afaik is why the react-docgen resolver does not pick it up as a valid component.

No suitable component definition found.

Is there an existing way to get this to work e.g. with a custom resolver? Or is a bugfix/new feature needed?

#195 looks like it resolves this, and is marked as closed as the feature in v3. I've installed react-docgen@3.0.0-beta11 but still get the issue with the above 2 examples.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

styled-components と Glamorous の例で報告された「No suitable component definition found」エラーを再現し、その後 react-docgen resolver と #195 で参照されている変更を調査します。両方の例が、報告されたエラーなしに有効なコンポーネントとして認識されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, react, typescript
領域
documentation, tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。