2022-05-24
最近在看 CSS for JS 这门课,作者分享了几个 styled-components 的使用技巧,感觉很有用,记一下:组件用 styled-components 包一层时,会生成唯一 class 名、处理样式字符串、注入 CSS、再和原本的 className 合并;模板字符串里用了 props 的话,不同 props 会生成不同的 className 和 CSS(因为 props 的值要等运行时才能确定),但换成 CSS 变量配合 style 属性传参,就能共享同一个 className,减少生成的代码量;给纯展示、复用性强的组件单独导出一份只负责样式的 Wrapper,方便别的组件通过它来定制样式;包裹的标签不要都写成 div,用 as 按语义指定成 h1~h6、a、button 等;用 styled-components/macro 引入可以让生成的 className 带上更完整的信息,方便开发时检索定位。
Demystifying styled-components • Josh W. Comeau For so many React devs, styled-components seems kinda magical. It isn't at all clear how it uses traditional CSS features under-the-hood, and that lack of clarity can cause real problems when things go awry. In this post, we'll learn exactly how styled-components works by building our own mini-version. joshwcomeau.com 2022-05-24
手机又丢了,所以才有了这篇《我的一加 8T 装了啥?》:https://tan61.dev/blog/what-app-in-my-oneplus-8t
2022-05-24
终于等到了 GitHub Codespaces 的试用资格,收到邮件就迫不及待试了一下。所有 VS Code 的设置自动同步过来,不用任何配置就有一个最熟悉的编辑器,跟之前用得比较多的 Gitpod 比,开发体验还是有提升。期待云 IDE、云开发环境能发展得更成熟。
2022-05-24
用 Manico 来通过快捷键快速打开常用软件,这个功能在 Raycast 里给 App 配置 Hotkey 也能做到。不过 Manico 的作者已经维护了它差不多 10 年了。
2022-05-24
最近在看 proselog(https://github.com/proselog/proselog )的代码时看到用了 tRPC 这个库,顺手看了一下官方介绍。它要解决的问题跟 GraphQL 有点像:"Simple, strong types. Feels like a more elegant choice than plain REST or GraphQL when using TS in a monorepo."
tRPC - Move Fast and Break Nothing. End-to-end typesafe APIs made easy. End-to-end typesafe APIs for TypeScript. Write procedures on the server, call them from the client with their types, and serve them on any runtime. trpc.io