@fringeworks/react-icon-material-symbols 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.ja.md CHANGED
@@ -83,7 +83,9 @@ import '@fringeworks/react-icon-material-symbols/font-outlined.css';
83
83
 
84
84
  ### 大きさと色
85
85
 
86
- アイコンは `1em` の正方形の箱に描き、大きさは親の `font-size` を、色は `color` を受け継ぎます。文やボタンの中では、周りの文字と同じ大きさ・色になります。Material Symbols の付属のクラスのように 24px に固定しないので、24px にしたいときは `font-size` を指定します。
86
+ アイコンは正方形の箱に描き、色は `color` を受け継ぎます。大きさは、周りの文字と同じに見える大きさ(親の `font-size` の 1.25 倍)です。Material Symbols は字形の周りに余白が多く、1em では文字より小さく見えるためです(react-icon の `--frg-icon-glyphScale` を `1.25` にしています)。縦の位置は、どのフォントの日本語や英字と並べても真ん中がそろって見えるよう、文字のベースラインを基準に決めています(react-icon の「大きさ・位置・色」)。
87
+
88
+ Material Symbols の付属のクラスのように 24px に固定しないので、24px にしたいときは `font-size` を指定します(指定した大きさになります)。ボタンの中など、react-components の部品の中のアイコンは、部品が決めた大きさになります。
87
89
 
88
90
  ```tsx
89
91
  <MaterialSymbolOutlined
@@ -264,7 +266,7 @@ MaterialSymbolSharp(props: MaterialSymbolProps): ReactElement
264
266
 
265
267
  | クラス | 説明 |
266
268
  | ------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------- |
267
- | `frg-icon`・`frg-fonticon` | react-icon のクラス(`1em` の正方形の箱と、アイコンフォントの指定) |
269
+ | `frg-icon`・`frg-fonticon` | react-icon のクラス(正方形の箱と、アイコンフォントの指定) |
268
270
  | `frg-materialsymbol` | Material Symbols のすべてのアイコン。可変フォントの軸を CSS 変数から組み立てる |
269
271
  | `frg-materialsymboloutlined`・`frg-materialsymbolrounded`・`frg-materialsymbolsharp` | 種類ごとのクラス。種類を選ぶためのもので、CSS の規則は持たない(フォントファミリーは部品が `style` で指定する) |
270
272
  | `frg-materialsymbol-opticalSize` | 光学サイズを固定するときに付く |
package/README.md CHANGED
@@ -83,7 +83,9 @@ Use `font-display: block` when you serve it yourself too. Icons are not drawn un
83
83
 
84
84
  ### Size and color
85
85
 
86
- Icons are drawn in a `1em` square box and inherit the parent's `font-size` and `color`. In text and buttons they match the size and color of the surrounding text. Unlike the classes that come with Material Symbols, the size is not fixed at 24px; set `font-size` when you want 24px.
86
+ Icons are drawn in a square box and inherit `color`. The size looks the same as the surrounding text (1.25 times the parent's `font-size`), because Material Symbols has a lot of space around the glyphs and looks smaller than the text at 1em (react-icon's `--frg-icon-glyphScale` is set to `1.25`). The vertical position is based on the baseline of the text, so that icons look centered next to Japanese and Latin text in any font (see "Size, position and color" in react-icon).
87
+
88
+ Unlike the classes that come with Material Symbols, the size is not fixed at 24px; set `font-size` when you want 24px (the icon gets that size). Icons inside components of react-components, such as buttons, get the size the component decides.
87
89
 
88
90
  ```tsx
89
91
  <MaterialSymbolOutlined
@@ -264,7 +266,7 @@ When you set `opticalSize` with a CSS variable, also add the `frg-materialsymbol
264
266
 
265
267
  | Class | Description |
266
268
  | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ |
267
- | `frg-icon`, `frg-fonticon` | react-icon classes (the `1em` square box and the icon font settings) |
269
+ | `frg-icon`, `frg-fonticon` | react-icon classes (the square box and the icon font settings) |
268
270
  | `frg-materialsymbol` | Every Material Symbols icon. Builds the variable font axes from CSS variables |
269
271
  | `frg-materialsymboloutlined`, `frg-materialsymbolrounded`, `frg-materialsymbolsharp` | One per style, for selecting a style. They have no CSS rules (the component sets the font family in `style`) |
270
272
  | `frg-materialsymbol-opticalSize` | Added when the optical size is fixed |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fringeworks/react-icon-material-symbols",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "A library some will find handy, for using Material Symbols as typed React components with variable font axes.",
5
5
  "keywords": [
6
6
  "react",
@@ -69,8 +69,8 @@
69
69
  "module": "./index.mjs",
70
70
  "types": "./index.d.cts",
71
71
  "dependencies": {
72
- "@fringeworks/react-contract": "^0.3.0",
73
- "@fringeworks/react-icon": "^0.1.1",
72
+ "@fringeworks/react-contract": "^0.3.1",
73
+ "@fringeworks/react-icon": "^0.2.0",
74
74
  "@fringeworks/react-merge": "^0.9.2",
75
75
  "material-symbols": "^0.49.0"
76
76
  },
package/styles.css CHANGED
@@ -1,14 +1,22 @@
1
1
  :where(.frg-icon) {
2
- display: inline-block;
2
+ display: inline-flex;
3
3
  flex-shrink: 0;
4
+ align-items: center;
5
+ justify-content: center;
4
6
  box-sizing: content-box;
5
7
  width: 1em;
6
8
  height: 1em;
7
- overflow: hidden;
8
- vertical-align: -0.125em;
9
+ clip-path: inset(0);
10
+ font-size: var(--frg-icon-size, calc(1em * var(--frg-icon-scale, 1) * var(--frg-icon-glyphScale, 1)));
9
11
  line-height: 1;
10
12
  }
11
13
 
14
+ :where(.frg-icon)::before {
15
+ content: "";
16
+ align-self: center;
17
+ margin-top: calc(2 * var(--frg-icon-centerY, 0.37) * 1em / (var(--frg-icon-scale, 1) * var(--frg-icon-glyphScale, 1)));
18
+ }
19
+
12
20
  :where(.frg-fonticon) {
13
21
  font-style: normal;
14
22
  font-weight: normal;
@@ -25,7 +33,14 @@
25
33
  user-select: none;
26
34
  }
27
35
 
36
+ :where(.frg-svgicon) > svg {
37
+ display: block;
38
+ width: 100%;
39
+ height: 100%;
40
+ }
41
+
28
42
  :where(.frg-materialsymbol) {
43
+ --frg-icon-glyphScale: 1.25;
29
44
  font-weight: var(--frg-materialsymbol-fontWeight, 400);
30
45
  font-variation-settings: "FILL" var(--frg-materialsymbol-filled, 0), "GRAD" var(--frg-materialsymbol-grade, 0);
31
46
  }