Skip to content

Commit

Permalink
Make activeFontFamily and onChange props optional
Browse files Browse the repository at this point in the history
For consistency with the `font-picker` package.
  • Loading branch information
samuelmeuli committed Apr 23, 2020
1 parent 6d5374a commit ebdbe7c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ When the user selects a font, it will automatically be downloaded and applied to
The following props can be passed to the `FontPicker` component:

- **`apiKey` (required)**: Google API key
- **`activeFontFamily` (required)**: Font that should be selected in the font picker and applied to the text. Should be stored in the component state and updated using `onChange`
- **`onChange` (required)**: Function which is executed when the user changes the active font. This function should update `activeFontFamily` in the component state
- **`activeFontFamily`**: Font that should be selected in the font picker and applied to the text. Should be stored in the component state and updated using `onChange`
- **`onChange`**: Function which is executed when the user changes the active font. This function should update `activeFontFamily` in the component state
- **`pickerId`**: If you have multiple font pickers on your site, you need to give them unique IDs which must be provided as a prop and appended to the `.apply-font` class names. Example: If `pickerId="main"`, use `className="apply-font-main"`
- **`families`**: If only specific fonts shall appear in the list, specify their names in an array. Default: All font families
- **`categories`**: Array of font categories to include in the list. Possible values: `"sans-serif", "serif", "display", "handwriting", "monospace"`. Default: All categories
Expand Down
9 changes: 4 additions & 5 deletions src/FontPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ type LoadingStatus = "loading" | "finished" | "error";
interface Props {
// Required props
apiKey: string;
activeFontFamily: string;
onChange: (font: Font) => void;

// Optional props
activeFontFamily: string;
onChange: (font: Font) => void;

This comment has been minimized.

Copy link
@lnmunhoz

This comment has been minimized.

Copy link
@samuelmeuli

samuelmeuli Apr 25, 2020

Author Owner

This commit is unrelated to #28. It fixes inconsistencies between code and docs.

pickerId: string;
families: string[];
categories: Category[];
Expand Down Expand Up @@ -47,7 +47,8 @@ export default class FontPicker extends PureComponent<Props, State> {
fontManager: FontManager;

static defaultProps = {
defaultFamily: FONT_FAMILY_DEFAULT,
activeFontFamily: FONT_FAMILY_DEFAULT,
onChange: (): void => {}, // eslint-disable-line @typescript-eslint/no-empty-function
pickerId: OPTIONS_DEFAULTS.pickerId,
families: OPTIONS_DEFAULTS.families,
categories: OPTIONS_DEFAULTS.categories,
Expand All @@ -56,8 +57,6 @@ export default class FontPicker extends PureComponent<Props, State> {
filter: OPTIONS_DEFAULTS.filter,
limit: OPTIONS_DEFAULTS.limit,
sort: OPTIONS_DEFAULTS.sort,
// eslint-disable-next-line @typescript-eslint/no-empty-function
onChange: (): void => {},
};

state: Readonly<State> = {
Expand Down

0 comments on commit ebdbe7c

Please sign in to comment.