Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fontfamily prop #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ Override border color
<Avvvatars value="best_user@gmail.com" borderColor="#fff" />
```

### `fontFamily?: string (default -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif)`

Override font family

```jsx
<Avvvatars value="best_user@gmail.com" fontFamily="Verdana,sans-serif" />
```

## Figma

If you want to access design files to change something or customize it to your own, use our [Figma File](https://www.figma.com/community/file/1084861895116393858/Avvvatars.com---Open-Source-React-UI-Avatar-Library-(Community))
Expand Down
13 changes: 10 additions & 3 deletions dist/avvvatars-react.cjs.development.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/avvvatars-react.cjs.development.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/avvvatars-react.cjs.production.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/avvvatars-react.cjs.production.min.js.map

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions dist/avvvatars-react.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/avvvatars-react.esm.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ interface Params {
size?: number;
shadow?: boolean;
style?: Style;
fontFamily?: string;
border?: boolean;
borderSize?: number;
borderColor?: string;
Expand Down
12 changes: 9 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const DEFAULTS = {
style: "character",
size: 32,
shadow: false,
fontFamily: `-apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif`,

border: false,
borderSize: 2,
Expand Down Expand Up @@ -64,14 +65,14 @@ const Wrapper = styled('div')<WrapperProps>`
`

// implement size
const Text = styled('p')<{ color: string, size: number }>`
const Text = styled('p')<{ color: string, size: number, fontFamily: string }>`
/* Reset */
margin: 0;
padding: 0;
text-align: center;
box-sizing: border-box;

font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
font-family: ${p => p.fontFamily};

font-size: ${p => Math.round(p.size / 100 * 37)}px;
color: #${p => p.color};
Expand All @@ -89,6 +90,7 @@ interface Params
size?: number
shadow?: boolean
style?: Style
fontFamily?: string

// toggle border
border?: boolean
Expand All @@ -108,7 +110,8 @@ export default function Avvvatars(params: Params)
shadow = DEFAULTS.shadow,
border = DEFAULTS.border,
borderSize = DEFAULTS.borderSize,
borderColor = DEFAULTS.borderColor
borderColor = DEFAULTS.borderColor,
fontFamily = DEFAULTS.fontFamily
} = params

// get first two letters
Expand All @@ -120,6 +123,8 @@ export default function Avvvatars(params: Params)
// there is 60 shapes so generate between 1 and 60
const shapeKey = randiman({ value, min: 1, max: 60 })

console.log(fontFamily)

return (
<Wrapper
size={size}
Expand All @@ -134,6 +139,7 @@ export default function Avvvatars(params: Params)
<Text
color={TEXT_COLORS[key]}
size={size}
fontFamily={fontFamily}
>
{name}
</Text>
Expand Down