AVATAR_SIZE environment variable (#509)

* Add and configure AVATAR_SIZE environment variable

* updated pr

* update snapshot

---------

Co-authored-by: Techno Tim <timothystewart6@gmail.com>
This commit is contained in:
Maxim Tacu 2023-11-18 05:00:46 +00:00 committed by GitHub
parent 96d3680397
commit 41654b9325
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 0 deletions

View File

@ -20,6 +20,7 @@ exports[`<App /> <App /> snapshot 1`] = `
>
<img
className="avatar"
style={Object {}}
/>
<h1>
undefined

View File

@ -1,11 +1,13 @@
import React, { memo } from 'react';
import { string } from 'prop-types';
import { addShadow } from '../../utils';
import { runtimeConfig } from '../../config';
import './Avatar.css';
function Avatar(props) {
const { src, srcSet, alt } = props;
const avatarSize = runtimeConfig.AVATAR_SIZE || null;
return (
<img
@ -13,6 +15,7 @@ function Avatar(props) {
src={src}
srcSet={srcSet}
alt={alt}
style={avatarSize ? { width: avatarSize, height: avatarSize } : {}}
/>
);
}

View File

@ -3,5 +3,6 @@
exports[`<Avatar /> <Avatar /> snapshot 1`] = `
<img
className="avatar"
style={Object {}}
/>
`;

View File

@ -17,6 +17,7 @@ exports[`<Home /> <Home /> snapshot 1`] = `
>
<img
className="avatar"
style={Object {}}
/>
<h1>
undefined

View File

@ -16,6 +16,7 @@ export const runtimeConfig =
THEME: window?.env?.THEME,
FAVICON_URL: window?.env?.FAVICON_URL,
AVATAR_URL: window?.env?.AVATAR_URL,
AVATAR_SIZE: window?.env?.AVATAR_SIZE,
AVATAR_ALT: window?.env?.AVATAR_ALT,
AVATAR_2X_URL: window?.env?.AVATAR_2X_URL,
NAME: window?.env?.NAME,
@ -183,6 +184,9 @@ export const runtimeConfig =
AVATAR_URL: nodeIsProduction
? process.env.AVATAR_URL
: process.env.RAZZLE_AVATAR_URL,
AVATAR_SIZE: nodeIsProduction
? process.env.AVATAR_SIZE
: process.env.RAZZLE_AVATAR_SIZE,
AVATAR_ALT: nodeIsProduction
? process.env.AVATAR_ALT
: process.env.RAZZLE_AVATAR_ALT,