mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-25 03:49:11 +00:00
fix(Editor): add empty role picker help page and link
This commit is contained in:
parent
30b9ea3a59
commit
d8cdc1c62a
5 changed files with 152 additions and 25 deletions
|
@ -1,6 +1,7 @@
|
||||||
import { Role } from '@roleypoly/design-system/atoms/role';
|
import { Role } from '@roleypoly/design-system/atoms/role';
|
||||||
import { Space } from '@roleypoly/design-system/atoms/space';
|
import { Space } from '@roleypoly/design-system/atoms/space';
|
||||||
import { TextInputWithIcon } from '@roleypoly/design-system/atoms/text-input';
|
import { TextInputWithIcon } from '@roleypoly/design-system/atoms/text-input';
|
||||||
|
import { Link } from '@roleypoly/design-system/atoms/typography';
|
||||||
import { Role as RoleType } from '@roleypoly/types';
|
import { Role as RoleType } from '@roleypoly/types';
|
||||||
import Fuse from 'fuse.js';
|
import Fuse from 'fuse.js';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
@ -32,21 +33,36 @@ export const RoleSearch = (props: Props) => {
|
||||||
<div>
|
<div>
|
||||||
<TextInputWithIcon
|
<TextInputWithIcon
|
||||||
icon={<GoSearch />}
|
icon={<GoSearch />}
|
||||||
placeholder={props.placeholder || 'Search or drag a role...'}
|
placeholder={props.placeholder || 'Search for a role...'}
|
||||||
value={props.searchTerm}
|
value={props.searchTerm}
|
||||||
onChange={(x) => props.onSearchUpdate(x.target.value)}
|
onChange={(x) => props.onSearchUpdate(x.target.value)}
|
||||||
/>
|
/>
|
||||||
<Space />
|
<Space />
|
||||||
{results.map((resultRole, idx) => (
|
{props.roles.length > 0 ? (
|
||||||
<RoleInliner key={idx}>
|
results.length > 0 ? (
|
||||||
<Role
|
results.map((resultRole, idx) => (
|
||||||
selected={false}
|
<RoleInliner key={idx}>
|
||||||
role={resultRole.item}
|
<Role
|
||||||
onClick={handleClick(resultRole.item)}
|
selected={false}
|
||||||
key={`${idx}role`}
|
role={resultRole.item}
|
||||||
/>
|
onClick={handleClick(resultRole.item)}
|
||||||
</RoleInliner>
|
key={`${idx}role`}
|
||||||
))}
|
/>
|
||||||
|
</RoleInliner>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<i>
|
||||||
|
No roles could be found. Try a different search term.
|
||||||
|
<br />
|
||||||
|
</i>
|
||||||
|
)
|
||||||
|
) : (
|
||||||
|
<i>
|
||||||
|
Roleypoly can't see any more roles.
|
||||||
|
<br />
|
||||||
|
<Link href="/help/why-no-roles">Learn why</Link>
|
||||||
|
</i>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import { numberToChroma, palette } from '@roleypoly/design-system/atoms/colors';
|
import { numberToChroma, palette } from '@roleypoly/design-system/atoms/colors';
|
||||||
import { Role } from '@roleypoly/types';
|
import { Role } from '@roleypoly/types';
|
||||||
import styled, { css } from 'styled-components';
|
import chroma from 'chroma-js';
|
||||||
|
import { GoCheck, GoQuestion, GoX } from 'react-icons/go';
|
||||||
|
import styled, { css, keyframes } from 'styled-components';
|
||||||
|
|
||||||
export const DiscordBase = styled.div`
|
export const DiscordBase = styled.div`
|
||||||
background-color: ${palette.discord100};
|
background-color: ${palette.discord100};
|
||||||
|
@ -17,9 +19,26 @@ const hover = (roleColor: string) => css`
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const isBadFlash = keyframes`
|
||||||
|
/* stylelint-disable function-name-case, function-whitespace-after */
|
||||||
|
|
||||||
|
0%, 100% {
|
||||||
|
box-shadow: 0 0 8px ${chroma(palette.red400).alpha(0.5).css()}
|
||||||
|
}
|
||||||
|
|
||||||
|
66% {
|
||||||
|
box-shadow: 0 0 2px ${chroma(palette.red200).alpha(0.5).css()}
|
||||||
|
}
|
||||||
|
|
||||||
|
33% {
|
||||||
|
box-shadow: 0 0 2px ${chroma(palette.red400).alpha(0.5).css()}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
export const DiscordRole = styled.div<{
|
export const DiscordRole = styled.div<{
|
||||||
discordRole: Role;
|
discordRole: Role;
|
||||||
isRoleypoly: boolean;
|
isRoleypoly: boolean;
|
||||||
|
isGood: boolean;
|
||||||
}>`
|
}>`
|
||||||
/* stylelint-disable function-name-case, function-whitespace-after */
|
/* stylelint-disable function-name-case, function-whitespace-after */
|
||||||
|
|
||||||
|
@ -35,4 +54,29 @@ export const DiscordRole = styled.div<{
|
||||||
|
|
||||||
${(props) =>
|
${(props) =>
|
||||||
props.isRoleypoly && hover(numberToChroma(props.discordRole.color).alpha(0.5).css())}
|
props.isRoleypoly && hover(numberToChroma(props.discordRole.color).alpha(0.5).css())}
|
||||||
|
${(props) =>
|
||||||
|
!props.isGood &&
|
||||||
|
props.isRoleypoly &&
|
||||||
|
css`
|
||||||
|
animation: ${isBadFlash} 0.5s 10s ease-in-out both;
|
||||||
|
`}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const bumpDown = css`
|
||||||
|
position: relative;
|
||||||
|
top: 0.1em;
|
||||||
|
margin-right: 0.25em;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const Dont = styled(GoX)`
|
||||||
|
${bumpDown}
|
||||||
|
color: ${palette.red400};
|
||||||
|
`;
|
||||||
|
export const Do = styled(GoCheck)`
|
||||||
|
${bumpDown}
|
||||||
|
color: ${palette.green400};
|
||||||
|
`;
|
||||||
|
export const Why = styled(GoQuestion)`
|
||||||
|
${bumpDown}
|
||||||
|
color: ${palette.discord400};
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
import { palette } from '@roleypoly/design-system/atoms/colors';
|
import { palette } from '@roleypoly/design-system/atoms/colors';
|
||||||
import { HalfsiesContainer, HalfsiesItem } from '@roleypoly/design-system/atoms/halfsies';
|
import { HalfsiesContainer, HalfsiesItem } from '@roleypoly/design-system/atoms/halfsies';
|
||||||
import { SparkleOverlay } from '@roleypoly/design-system/atoms/sparkle';
|
import { SparkleOverlay } from '@roleypoly/design-system/atoms/sparkle';
|
||||||
|
import { Toggle } from '@roleypoly/design-system/atoms/toggle';
|
||||||
|
import {
|
||||||
|
AmbientLarge,
|
||||||
|
LargeText,
|
||||||
|
SmallTitle,
|
||||||
|
} from '@roleypoly/design-system/atoms/typography';
|
||||||
import { Role } from '@roleypoly/types';
|
import { Role } from '@roleypoly/types';
|
||||||
import { demoData } from '@roleypoly/types/demoData';
|
import { demoData } from '@roleypoly/types/demoData';
|
||||||
import chroma from 'chroma-js';
|
import chroma from 'chroma-js';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { FaCheck, FaTimes } from 'react-icons/fa';
|
import { DiscordBase, DiscordRole, Do, Dont, Why } from './WhyNoRoles.styled';
|
||||||
import { DiscordBase, DiscordRole } from './WhyNoRoles.styled';
|
|
||||||
|
|
||||||
const adminRoles: Role[] = [
|
const adminRoles: Role[] = [
|
||||||
{
|
{
|
||||||
|
@ -60,7 +65,11 @@ const Example = (props: { roles: Role[]; isGood: boolean }) => (
|
||||||
<DiscordBase>
|
<DiscordBase>
|
||||||
{props.roles.map((r) => (
|
{props.roles.map((r) => (
|
||||||
<MaybeWithOverlay withOverlay={props.isGood && r.name === 'Roleypoly'}>
|
<MaybeWithOverlay withOverlay={props.isGood && r.name === 'Roleypoly'}>
|
||||||
<DiscordRole discordRole={r} isRoleypoly={r.name === 'Roleypoly'}>
|
<DiscordRole
|
||||||
|
discordRole={r}
|
||||||
|
isRoleypoly={r.name === 'Roleypoly'}
|
||||||
|
isGood={props.isGood}
|
||||||
|
>
|
||||||
{r.name}
|
{r.name}
|
||||||
</DiscordRole>
|
</DiscordRole>
|
||||||
</MaybeWithOverlay>
|
</MaybeWithOverlay>
|
||||||
|
@ -70,14 +79,50 @@ const Example = (props: { roles: Role[]; isGood: boolean }) => (
|
||||||
);
|
);
|
||||||
|
|
||||||
export const WhyNoRoles = () => (
|
export const WhyNoRoles = () => (
|
||||||
<HalfsiesContainer>
|
<div>
|
||||||
<HalfsiesItem>
|
<p>
|
||||||
<FaCheck /> Good
|
<SmallTitle>Why can't I see my roles?</SmallTitle>
|
||||||
<Example isGood roles={goodRoles} />
|
</p>
|
||||||
</HalfsiesItem>
|
<HalfsiesContainer>
|
||||||
<HalfsiesItem>
|
<HalfsiesItem>
|
||||||
<FaTimes /> Baddd
|
<Do />
|
||||||
<Example isGood={false} roles={badRoles} />
|
<b>DO:</b> Roleypoly is above the other roles
|
||||||
</HalfsiesItem>
|
<Example isGood roles={goodRoles} />
|
||||||
</HalfsiesContainer>
|
</HalfsiesItem>
|
||||||
|
<HalfsiesItem>
|
||||||
|
<Dont />
|
||||||
|
<b>DON'T:</b> Roleypoly is below the other roles
|
||||||
|
<Example isGood={false} roles={badRoles} />
|
||||||
|
</HalfsiesItem>
|
||||||
|
</HalfsiesContainer>
|
||||||
|
|
||||||
|
<AmbientLarge>
|
||||||
|
<Why />
|
||||||
|
{' '}
|
||||||
|
Discord doesn't let members/bots with "manage roles" permissions assign roles above
|
||||||
|
their highest role.
|
||||||
|
</AmbientLarge>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<LargeText>Other tips:</LargeText>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<Do />
|
||||||
|
<b>DO:</b> Roles have no elevated permissions.
|
||||||
|
<Toggle state={false}>Administrator</Toggle>
|
||||||
|
<Toggle state={false}>Manage Roles</Toggle>
|
||||||
|
<br />
|
||||||
|
<Dont />
|
||||||
|
<b>DON'T:</b> Roles cannot have Administrator or Manage Roles permissions.
|
||||||
|
<Toggle state={true}>Administrator</Toggle>
|
||||||
|
<Toggle state={true}>Manage Roles</Toggle>
|
||||||
|
<AmbientLarge>
|
||||||
|
<Why />
|
||||||
|
{' '}
|
||||||
|
These permissions give access to the Roleypoly editor and Discord tools, which can
|
||||||
|
open your server up to vandalism.
|
||||||
|
</AmbientLarge>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import ErrorPage from '../pages/error';
|
||||||
import LandingPage from '../pages/landing';
|
import LandingPage from '../pages/landing';
|
||||||
import PickerPage from '../pages/picker';
|
import PickerPage from '../pages/picker';
|
||||||
|
|
||||||
|
const WhyNoRoles = React.lazy(() => import('../pages/help/why-no-roles'));
|
||||||
const ServersPage = React.lazy(() => import('../pages/servers'));
|
const ServersPage = React.lazy(() => import('../pages/servers'));
|
||||||
const EditorPage = React.lazy(() => import('../pages/editor'));
|
const EditorPage = React.lazy(() => import('../pages/editor'));
|
||||||
|
|
||||||
|
@ -50,6 +51,8 @@ export const AppRouter = () => {
|
||||||
<RouteWrapper component={DevToolsSetApi} path="/x/dev-tools/set-api" />
|
<RouteWrapper component={DevToolsSetApi} path="/x/dev-tools/set-api" />
|
||||||
<RouteWrapper component={DevToolsSessionDebug} path="/x/dev-tools/session-debug" />
|
<RouteWrapper component={DevToolsSessionDebug} path="/x/dev-tools/session-debug" />
|
||||||
|
|
||||||
|
<RouteWrapper component={WhyNoRoles} path="/help/why-no-roles" />
|
||||||
|
|
||||||
<RouteWrapper component={ErrorPage} default identity={404} />
|
<RouteWrapper component={ErrorPage} default identity={404} />
|
||||||
</Router>
|
</Router>
|
||||||
);
|
);
|
||||||
|
|
19
packages/web/src/pages/help/why-no-roles.tsx
Normal file
19
packages/web/src/pages/help/why-no-roles.tsx
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import { WhyNoRoles } from '@roleypoly/design-system/organisms/help-why-no-roles';
|
||||||
|
import { HelpPageTemplate } from '@roleypoly/design-system/templates/help-page';
|
||||||
|
import { useAppShellProps } from '../../contexts/app-shell/AppShellContext';
|
||||||
|
import { Title } from '../../utils/metaTitle';
|
||||||
|
|
||||||
|
const WhyNoRolesPage = () => {
|
||||||
|
const appShellProps = useAppShellProps();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Title title="Why can't I see my roles? - Roleypoly Help" />
|
||||||
|
<HelpPageTemplate {...appShellProps}>
|
||||||
|
<WhyNoRoles />
|
||||||
|
</HelpPageTemplate>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default WhyNoRolesPage;
|
Loading…
Add table
Reference in a new issue