Skip to content

Commit

Permalink
enhancement: Misc design updates, fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Betree committed Feb 6, 2024
1 parent 3353aba commit 068a76a
Show file tree
Hide file tree
Showing 20 changed files with 365 additions and 231 deletions.
12 changes: 10 additions & 2 deletions app/API/socket_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,16 @@ class CaptainFactSocketApi {

createSocket(token) {
this.socket = new Socket(this.socketUrl, { params: { token } })
this.socket.onError(noInternetError)
this.socket.onClose(noInternetError)
this.socket.onError((e) => {
// eslint-disable-next-line no-console
console.warning('Socket error:', e)
noInternetError()
})
this.socket.onClose((e) => {
if (!e.wasClean) {
noInternetError()
}
})
}

/**
Expand Down
67 changes: 44 additions & 23 deletions app/components/App/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import SearchBox from '../Search/SearchBox'
import Container from '../StyledUtils/Container'
import { fadeIn } from '../StyledUtils/Keyframes'
import StyledLink from '../StyledUtils/StyledLink'
import { Span } from '../StyledUtils/Text'
import ScoreTag from '../Users/ScoreTag'
import UserAppellation from '../Users/UserAppellation'
import UserMenu from '../Users/UserMenu'
import UserPicture from '../Users/UserPicture'
import { ErrorView } from '../Utils/ErrorView'
Expand Down Expand Up @@ -63,8 +65,13 @@ const UserMenuEntry = styled((props) => <StyledLink {...omit(props, 'isActive')}
display: block;
border-left: 2px solid white;
background: white;
font-size: 1.1em;
padding: 10px 15px;
outline: none;
&:hover {
&:hover,
&:active,
&:focus {
background: ${themeGet('colors.black.50')};
}
Expand All @@ -81,10 +88,13 @@ const UserMenuEntry = styled((props) => <StyledLink {...omit(props, 'isActive')}
`}
`

UserMenuEntry.defaultProps = {
px: 2,
py: 1,
}
const UserHero = styled.div`
display: flex;
align-items: center;
gap: 8px;
border-bottom: 1px solid ${themeGet('colors.black.100')};
padding: 10px 15px;
`

const ScoreHelpButton = styled(HelpCircle)`
color: #39b714;
Expand Down Expand Up @@ -117,7 +127,7 @@ const NotificationPopup = styled(StyledPopup)`
`
const MenuPopup = styled(StyledPopup)`
&-content {
width: 200px;
min-width: 200px;
}
`

Expand Down Expand Up @@ -219,23 +229,34 @@ const Navbar = ({
</UserMenuTrigger>
}
>
<UserMenu user={loggedInUser} hasLogout isSelf>
{({ Icon, key, route, title, index, isActive, onClick }) => (
<UserMenuEntry
key={key}
to={route}
index={index}
isActive={isActive}
onClick={onClick}
>
<Box>
<Icon size="1em" />
&nbsp;
{title}
</Box>
</UserMenuEntry>
)}
</UserMenu>
<div>
<UserHero>
<UserPicture size={USER_PICTURE_LARGE} user={loggedInUser} />
<Flex flexDirection="column" justifyContent="center">
<UserAppellation user={loggedInUser} withoutActions />
<Span fontSize="0.8em" color="black.500">
{loggedInUser.email}
</Span>
</Flex>
</UserHero>
<UserMenu user={loggedInUser} hasLogout isSelf>
{({ Icon, key, route, title, index, isActive, onClick }) => (
<UserMenuEntry
key={key}
to={route}
index={index}
isActive={isActive}
onClick={onClick}
>
<Box>
<Icon size="1em" />
&nbsp;
{title}
</Box>
</UserMenuEntry>
)}
</UserMenu>
</div>
</MenuPopup>
</Flex>
) : (
Expand Down
7 changes: 7 additions & 0 deletions app/components/App/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,19 @@ export default class Sidebar extends React.PureComponent {

MenuLink({ title, iconName, customLink, className, children, ...props }) {
const classes = classNames(className, { 'link-with-icon': !!iconName })

return (
<NavLink
className={classes}
activeClassName="is-active"
onClick={this.closeSideBarIfMobile}
title={title ? title : children}
// For `/help/contact`, override the default `isActive` as we would activate both help and contact otherwise
isActive={
props.to === '/help'
? (match, location) => (location.pathname === '/help/contact' ? false : match)
: null
}
{...props}
>
{iconName && <RawIcon name={iconName} />}
Expand Down
27 changes: 10 additions & 17 deletions app/components/Home/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default class Home extends React.PureComponent {
<p>
<Link
onClick={() => Matomo.registerClick('Home', 'Button', 'ExtensionPage')}
className="button is-primary is-medium"
className="button is-medium"
to="/extension"
>
{t('installExtension')}
Expand All @@ -62,7 +62,7 @@ export default class Home extends React.PureComponent {
<p>
<Link
onClick={() => Matomo.registerClick('Home', 'Button', 'SignUp')}
className="button is-secondary is-medium"
className="button is-gradient-primary-light is-medium"
to="/signup"
>
{t('registerAndFactCheck')}
Expand Down Expand Up @@ -92,7 +92,7 @@ export default class Home extends React.PureComponent {
</div>
</section>

{this.props.lng === 'fr' && (
{this.props.lng === 'fr' && process.env.HIDE_FR_SITE !== 'true' && (
<section className="section know-more-fr has-text-centered">
<p className="has-text-weight-semibold">
{t('knowMoreFR')}
Expand Down Expand Up @@ -128,10 +128,7 @@ export default class Home extends React.PureComponent {
脡quipe
</ExternalLinkNewTab>
<br />
<ExternalLinkNewTab
className="button is-primary is-large"
href="https://fr.captainfact.io"
>
<ExternalLinkNewTab className="button is-large" href="https://fr.captainfact.io">
{t('goToFRSite')}
</ExternalLinkNewTab>
</p>
Expand All @@ -143,14 +140,13 @@ export default class Home extends React.PureComponent {
<h2 className="title is-3">{t('latest')}</h2>
<Link
onClick={() => Matomo.registerClick('Home', 'Button', 'SeeAllVideos')}
className="button animated-hover is-medium is-gradient-primary-light"
className="button is-gradient-primary-light animated-hover is-medium"
to="/videos"
>
{t('seeVideos')}
</Link>
</div>
<br />
<br />
<div className="last-videos-cards">
<LastVideos />
</div>
Expand Down Expand Up @@ -211,7 +207,7 @@ export default class Home extends React.PureComponent {
</p>
<Link
onClick={() => Matomo.registerClick('Home', 'Button', 'ExtensionPage')}
className="button is-primary is-medium"
className="button is-medium"
to="/extension"
>
{t('installExtension')}
Expand All @@ -230,7 +226,7 @@ export default class Home extends React.PureComponent {
</p>
<Link
onClick={() => Matomo.registerClick('Home', 'Button', 'SignUp')}
className="button is-primary is-medium"
className="button is-medium"
to="/signup"
>
{t('registerAndFactCheck')}
Expand Down Expand Up @@ -262,7 +258,7 @@ export default class Home extends React.PureComponent {
<br />
</p>
<ExternalLinkNewTab
className="button is-primary is-medium"
className="button is-medium"
href="https://github.com/CaptainFact/captain-fact/wiki/Les-partenariats-entre-les-cha卯nes-Youtube-et-CaptainFact.io"
>
{t('learnMore')} (fr)
Expand Down Expand Up @@ -296,15 +292,12 @@ export default class Home extends React.PureComponent {
</div>
</section>

{this.props.lng === 'fr' && (
{this.props.lng === 'fr' && process.env.HIDE_FR_SITE !== 'true' && (
<section className="section know-more-fr has-text-centered">
<p className="has-text-weight-semibold">
{t('knowMoreFR')}
<br />
<ExternalLinkNewTab
className="button is-primary is-large"
href="https://fr.captainfact.io"
>
<ExternalLinkNewTab className="button is-large" href="https://fr.captainfact.io">
{t('goToFRSite')}
</ExternalLinkNewTab>
</p>
Expand Down
8 changes: 6 additions & 2 deletions app/components/Moderation/Moderation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class Moderation extends React.PureComponent {
}

return (
<div className="section">
<div id="moderation-page" className="section">
<h1 className="title is-1 has-text-centered">
{t('title')} <Report size="1em" />
</h1>
Expand All @@ -52,7 +52,11 @@ export default class Moderation extends React.PureComponent {
{t('learnMore')}
</Link>
</div>
{!entry && <Message className="has-text-centered">{t('emptyModeration')}</Message>}
{!entry && (
<Message mt={4} className="has-text-centered mt-6">
{t('emptyModeration')}
</Message>
)}
{entry && (
<div>
{this.renderAction(entry.action)}
Expand Down
2 changes: 1 addition & 1 deletion app/components/Users/PublicAchievementUnlocker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class PublicAchievementUnlocker extends React.PureComponent {
const achievementTitle = this.props.t(`${this.props.achievementId}.title`)
this.props.flashSuccessMsg('achievements:unlocked', {
i18nParams: { achievement: achievementTitle },
infoUrl: `/u/${this.props.loggedInUser.username}`,
infoUrl: `/u/${this.props.loggedInUser.username}/profile`,
iconName: 'trophy',
})
})
Expand Down
18 changes: 13 additions & 5 deletions app/components/Utils/FacetButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const Wrapper = styled.button`
border-radius: 50%;
transition:
opacity 0.3s,
color 0.3s;
color 0.1s;
backface-visibility: hidden;
overflow: visible;
padding: ${({ size }) => `${size / 4}px`};
Expand All @@ -52,11 +52,12 @@ const Wrapper = styled.button`
/* Activated icon */
&:nth-child(1) {
color: ${themeGet('colors.yellow')};
color: ${(props) =>
props.$isSecondary ? props.theme.colors.secondary : props.theme.colors.black[400]};
transform: rotateY(180deg);
&:hover {
opacity: 0.7;
color: ${themeGet('colors.primary')};
}
}
Expand All @@ -66,7 +67,7 @@ const Wrapper = styled.button`
opacity: ${({ activated }) => (activated ? 0 : 0.7)};
&:hover {
color: #e2b26f;
color: ${themeGet('colors.black.500')};
}
}
}
Expand All @@ -81,9 +82,16 @@ const FacetButton = ({
size,
keepTooltipInside,
className,
isSecondary,
}) => {
const popupContent = (
<Wrapper activated={activated} onClick={onClick} size={size} className={className}>
<Wrapper
activated={activated}
onClick={onClick}
size={size}
$isSecondary={isSecondary}
className={className}
>
{activatedIcon}
{deactivatedIcon || activatedIcon}
</Wrapper>
Expand Down
Loading

0 comments on commit 068a76a

Please sign in to comment.