Path: blob/master/src/packages/frontend/components/font-size.tsx
1503 views
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { CSSProperties, useMemo } from "react";67import { DropdownMenu, Icon } from "@cocalc/frontend/components";8import { FONT_SIZES } from "@cocalc/frontend/editors/editor-button-bar";9import { MenuItems } from "./dropdown-menu";1011interface Props {12onClick: (family: string) => void;13style?: CSSProperties;14}1516export default function FontSizeMenu({ onClick, style }: Props) {17const items: MenuItems = useMemo(() => {18return FONT_SIZES.map((size) => {19return {20key: size,21onClick: () => onClick(size),22label: (23<span style={{ fontSize: size }}>24{size} {size === "medium" ? "(default)" : undefined}25</span>26),27};28});29}, [onClick]);3031return (32<DropdownMenu33style={style}34button={true}35title={<Icon name={"text-height"} />}36key={"font-size"}37items={items}38/>39);40}414243