日本では4月4日に抽選販売の応募が開始された、任天堂の新ハード「Nintendo Switch 2」。当初、米国では4月9日から予約受付を開始する予定だったが、遅れることが明らかになった。
Source link
Views: 0
Views: 0
React Hook Form は、Reactでフォームを扱いやすくするためのライブラリです。
React では通常、フォームの各入力欄を useState で管理し、それを集めてバリデーションして…という処理が必要になります。
React Hook Form を使うと、そういった作業を簡潔に書けるようになります。
具体的には以下のようなことができます:
React Hook Form の中核は useForm()
というカスタムフックです。
これは React の Hook システム(useState や useEffect など)と同じ考え方で、フォームの状態を扱えるようにしたものです。
React の設計に沿っているため、シンプルなコードが書けます
まずは useForm を使って、フォーム全体の管理を準備します。
import { useForm } from "react-hook-form";
const { register, handleSubmit, formState: { errors } } = useForm();
register
handleSubmit
errors
次に、フォームの中にある や
に
register
を使って登録します。
input {...register("title", { required: "タイトルは必須です" })} />
ここで "title"
はフィールド名です。オブジェクト形式でバリデーションルールも指定できます。
バリデーションエラーがある場合は、errors
に情報が入ります。
それを使って、該当する入力欄の下にエラー文を表示します。
{errors.title && p>{errors.title.message}p>}
送信時には handleSubmit
を使います。
バリデーションが通ったときのみ、引数で指定した関数が呼ばれます。
const onSubmit = (data) => {
console.log(data); // data は各 register() に対応する値のまとまり
};
form onSubmit={handleSubmit(onSubmit)}>
{/* 各 input 要素 */}
button type="submit">送信button>
form>
register("time", {
required: "時間の入力は必須です",
min: {
value: 1,
message: "時間は0以上である必要があります"
}
})
ちなみに、loadingはサポートしてなかったので今回私はそこだけuseStateを使いました。
ここに貼ってあるコードをコピペして使いました
Views: 0
目次
デザインシステムと開発の現状課題
MCP サーバーの登場
Ubie UI…
Source link
Views: 0
Back in the day I was a fan of the “Trebuchet MS” font. I didn’t like it large, but set fairly small I loved the look of it. Looked very website-ish — if that makes sense.
Honestly, at 12px, it still looks really nice.
The main reason I would use it is that it was considered a “web-safe” font, meaning most computers had “Trebuchet MS” installed and it would look more or less the same across those computers. On my latest-version macOS, I’ve still got it as a pre-installed system font.
I was thinking about this as Oliver Schöndorfer blogged about it recently. He points out that mobile operating systems changed the math on what is actually “web safe”.
Web-safe fonts system fonts that are pre-installed on most browsers and operating systems. While this was true 15 years ago, when you would find Arial, Times New Roman, Georgia or Verdana on Windows and Apple machines, this drastically changed with the mobile era.
Apparently none of the classic web-safe fonts are actually “web safe” anymore, which I suppose is ironic and kinda funny. I think designers have gotten more used to and OK with some differences in typography across browsers. Modern Font Stacks is a great resource for that. The whole point of a font stack is being cool with the actually used font being whichever one hits first in that list. The whole idea of system-ui
is like a font stack in a keyword by itself, and particularly well suited to very “app like” websites that are helped by looking like the operating system they are being used on. Maybe the new web safe is just typography that works fine wherever. Or maybe that’s what it always meant.
Along those lines, I think uifonts.app is a clever idea of looking at fonts in a very practical “app like” way. I like looking at beautiful typeface type specimens as much as the next fella but in the end it matters more what the typeface looks like on my boring thing not your fancy thing.
system-ui
as an option!Quick hits:
-webkit-font-smoothing: antialiased;
but David Bushell almost has me convinced otherwise as 1) it’s macOS (very literally only) 2) it can make rendered fonts look closer to other operating systems, that is, thinner. My holdup is that I generally like thicker and it will be more consistent for users on that OS. But David is convinced enough to put it in reset stylesheets, so have a think for yourself.And some more visuals!
Views: 0
Views: 0
Views: 0
The sale date form when clicking on the “set up your sale” link formats the dates in a format the form can’t read, so the sale cannot be submitted unless you change the date to a different day and then back again
It throws the following error:
Errors:
I’m excited to see what goodies are avaialble for a good price this week!
Views: 0
Views: 0
Views: 0