Merge pull request #163 from arifszn/142-avatar-ring

Control avatar ring visibility
This commit is contained in:
Ariful Alam
2022-09-08 22:04:04 +06:00
committed by GitHub
6 changed files with 30 additions and 3 deletions

View File

@@ -9,6 +9,9 @@
<a href="https://codeclimate.com/github/arifszn/gitprofile/maintainability"> <a href="https://codeclimate.com/github/arifszn/gitprofile/maintainability">
<img src="https://api.codeclimate.com/v1/badges/c60f42d7d0b61bd33e98/maintainability" /> <img src="https://api.codeclimate.com/v1/badges/c60f42d7d0b61bd33e98/maintainability" />
</a> </a>
<a href="https://github.com/arifszn/gitprofile/actions/workflows/test-deploy.yml">
<img src="https://github.com/arifszn/gitprofile/actions/workflows/test-deploy.yml/badge.svg" />
</a>
<a href="https://github.com/arifszn/gitprofile/issues"> <a href="https://github.com/arifszn/gitprofile/issues">
<img src="https://img.shields.io/github/issues/arifszn/gitprofile"/> <img src="https://img.shields.io/github/issues/arifszn/gitprofile"/>
</a> </a>
@@ -234,6 +237,9 @@ const config = {
// using user system preferences, instead of the hardcoded defaultTheme // using user system preferences, instead of the hardcoded defaultTheme
respectPrefersColorScheme: true, respectPrefersColorScheme: true,
// Hide the ring in Profile picture
hideAvatarRing: false,
// Available themes. To remove any theme, exclude from here. // Available themes. To remove any theme, exclude from here.
themes: [ themes: [
'light', 'light',

View File

@@ -98,6 +98,9 @@ const config = {
// using user system preferences, instead of the hardcoded defaultTheme // using user system preferences, instead of the hardcoded defaultTheme
respectPrefersColorScheme: false, respectPrefersColorScheme: false,
// Hide the ring in Profile picture
hideAvatarRing: false,
// Available themes. To remove any theme, exclude from here. // Available themes. To remove any theme, exclude from here.
themes: [ themes: [
'light', 'light',

View File

@@ -156,7 +156,11 @@ const GitProfile = ({ config }) => {
themeConfig={sanitizedConfig.themeConfig} themeConfig={sanitizedConfig.themeConfig}
/> />
)} )}
<AvatarCard profile={profile} loading={loading} /> <AvatarCard
profile={profile}
loading={loading}
avatarRing={!sanitizedConfig.themeConfig.hideAvatarRing}
/>
<Details <Details
profile={profile} profile={profile}
loading={loading} loading={loading}
@@ -281,6 +285,7 @@ GitProfile.propTypes = {
defaultTheme: PropTypes.string, defaultTheme: PropTypes.string,
disableSwitch: PropTypes.bool, disableSwitch: PropTypes.bool,
respectPrefersColorScheme: PropTypes.bool, respectPrefersColorScheme: PropTypes.bool,
hideAvatarRing: PropTypes.bool,
themes: PropTypes.array, themes: PropTypes.array,
customTheme: PropTypes.shape({ customTheme: PropTypes.shape({
primary: PropTypes.string, primary: PropTypes.string,

View File

@@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
import { fallbackImage, skeleton } from '../../helpers/utils'; import { fallbackImage, skeleton } from '../../helpers/utils';
import LazyImage from '../lazy-image'; import LazyImage from '../lazy-image';
const AvatarCard = ({ profile, loading }) => { const AvatarCard = ({ profile, loading, avatarRing }) => {
return ( return (
<div className="card shadow-lg compact bg-base-100"> <div className="card shadow-lg compact bg-base-100">
<div className="grid place-items-center py-8"> <div className="grid place-items-center py-8">
@@ -18,7 +18,13 @@ const AvatarCard = ({ profile, loading }) => {
</div> </div>
) : ( ) : (
<div className="avatar opacity-90"> <div className="avatar opacity-90">
<div className="mb-8 rounded-full w-32 h-32 ring ring-primary ring-offset-base-100 ring-offset-2"> <div
className={`mb-8 rounded-full w-32 h-32 ${
avatarRing
? 'ring ring-primary ring-offset-base-100 ring-offset-2'
: ''
}`}
>
{ {
<LazyImage <LazyImage
src={profile.avatar ? profile.avatar : fallbackImage} src={profile.avatar ? profile.avatar : fallbackImage}
@@ -57,6 +63,7 @@ const AvatarCard = ({ profile, loading }) => {
AvatarCard.propTypes = { AvatarCard.propTypes = {
profile: PropTypes.object, profile: PropTypes.object,
loading: PropTypes.bool.isRequired, loading: PropTypes.bool.isRequired,
avatarRing: PropTypes.bool.isRequired,
}; };
export default AvatarCard; export default AvatarCard;

View File

@@ -177,6 +177,7 @@ export const sanitizeConfig = (config) => {
disableSwitch: config?.themeConfig?.disableSwitch || false, disableSwitch: config?.themeConfig?.disableSwitch || false,
respectPrefersColorScheme: respectPrefersColorScheme:
config?.themeConfig?.respectPrefersColorScheme || false, config?.themeConfig?.respectPrefersColorScheme || false,
hideAvatarRing: config?.themeConfig?.hideAvatarRing || false,
themes: themes, themes: themes,
customTheme: customTheme, customTheme: customTheme,
}, },

5
types/index.d.ts vendored
View File

@@ -186,6 +186,11 @@ export interface ThemeConfig {
*/ */
respectPrefersColorScheme?: boolean; respectPrefersColorScheme?: boolean;
/**
* Hide the ring in Profile picture
*/
hideAvatarRing?: boolean;
/** /**
* Available themes * Available themes
*/ */