Skip to content

feat(spindle-ui): convert SVG icon to React component#7

Merged
herablog merged 7 commits into
masterfrom
feature/ui-icon
Aug 27, 2020
Merged

feat(spindle-ui): convert SVG icon to React component#7
herablog merged 7 commits into
masterfrom
feature/ui-icon

Conversation

@herablog

@herablog herablog commented Aug 5, 2020

Copy link
Copy Markdown
Member

SVGRを使って、SVGからReactコンポーネントに変換しました。Spindleコンポーネント内でアイコン利用することがあるので、コンポーネント化しています。

SVGR Options

  • typescript : 他のコンポーネントに合わせてTypeScriptとして書き出します
  • icon: 親要素のフォントサイズを継承するため、1emをデフォルトサイズとして指定します
  • ignoreExisting: アイコン生成時に変更内容が反映されるようにします。差分はgitで管理します。

Storybook

icon-storybook

@herablog herablog requested a review from tokimari August 5, 2020 08:57
@herablog herablog self-assigned this Aug 5, 2020
@herablog herablog force-pushed the feature/ui-icon branch 2 times, most recently from 3ed3eb0 to 6fc23e0 Compare August 5, 2020 09:02
"build:style": "postcss src/**/*.css src/*.css --base src -d dist/"
"build:style": "postcss src/**/*.css src/*.css --base src -d dist/",
"preicon": "npx cpx '../spindle-icons/dist/!(sprite).svg' icon-tmp",
"icon": "svgr --out-dir src/Icon icon-tmp",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spindle-iconの更新と同じタイミングで実行するコマンドです。どこかしらで自動にするかは検討中・・・。

<div>
<Clock height="200" width="200"></Clock>
</div>
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代替テキストありverのstoryもあると嬉しいです!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

利用サンプルとしての属性をたしました〜 b5688ad

ボタン内で利用する際のサンプルは、<Button>の方に書く予定です。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

あ、むしろ role="img" は常に(デフォルトで)つけた方がいいかもです><イマサラ
代替テキストは不要なケースもありそうだけれども・・!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

そりね〜、デフォルトで入れるか、使う時に決めてもらうかと思ってたけど、Icon前提だから入れておきますか〜。

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

デフォルトのroleをimgにしました。
3fa1e2d

いちお、利用時に上書きも可能です。

@sasaplus1

Copy link
Copy Markdown
Member

Storybook開こうとしたらおこられました 😢

おこられ

@herablog

Copy link
Copy Markdown
Member Author

おこられ発生!! こりはもしや、生成からやってくれましたか!? なぜか ArrowDown が 複数書き込まれちゃう問題が・・。

@herablog

herablog commented Aug 26, 2020

Copy link
Copy Markdown
Member Author

わかった!! こっちが原因だ・・w arrow-down.svg, arrow_down.svg

https://github.com/openameba/spindle/tree/master/packages/spindle-icons/dist

@sasaplus1

Copy link
Copy Markdown
Member

yarn storybook:startしておこられ発生して、あれ〜と思ったのでyarn buildしてみてもおこられ発生って感じでしたw

とりあえずArrowDownを手動で1行消してStorybook見れました〜

@herablog

Copy link
Copy Markdown
Member Author

おかげさまで問題を発見できましたw SVGの方修正しますw

@herablog

Copy link
Copy Markdown
Member Author

@sasaplus1 #15 でSVGの修正をしました。ただこの間にアイコン更新されてたので、それも含めてになっちゃいました。(便乗PRですみませんw)

@herablog

Copy link
Copy Markdown
Member Author

#15 を取り込みつつ、以下の変更を加えました。

  • Icon書き出し直し a72dd99
  • 必要ないファイルが残らないように、Iconファイルを作り直す前に消す c1d2239
  • Iconのentry fileであるindex.js のバジェット更新 1910abd
    • このファイルはあまり意味ないと言うか、アイコン数と連動しますが・・

@sasaplus1 sasaplus1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

とりあえず無事にStorybook見れました〜:tada:

@herablog

Copy link
Copy Markdown
Member Author

おーありがとうございます!

@herablog herablog merged commit b1b5e3f into master Aug 27, 2020
@herablog herablog deleted the feature/ui-icon branch August 27, 2020 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants