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

Development #201

Merged
merged 14 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"private": true,
"dependencies": {
"@floating-ui/react": "0.26.1",
"@plebbit/plebbit-react-hooks": "https://github.com/plebbit/plebbit-react-hooks.git#80f19b488013cf386f4926fefb5790c79a3b9b96",
"@plebbit/plebbit-react-hooks": "https://github.com/plebbit/plebbit-react-hooks.git#6b614e0bf6c304de7b184564198a0ce7b98bca1d",
"@testing-library/jest-dom": "5.14.1",
"@testing-library/react": "13.0.0",
"@testing-library/user-event": "13.2.1",
Expand Down
4 changes: 2 additions & 2 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ function App() {
<Route path='/communities/admin' element={<Subplebbits />} />
<Route path='/communities/owner' element={<Subplebbits />} />
<Route path='/communities/vote' element={<Subplebbits />} />
<Route path='/communities/vote/passed' element={<Subplebbits />} />
<Route path='/communities/vote/rejected' element={<Subplebbits />} />
<Route path='/communities/vote/passing' element={<Subplebbits />} />
<Route path='/communities/vote/rejecting' element={<Subplebbits />} />
</Route>
</Route>
</Routes>
Expand Down
8 changes: 1 addition & 7 deletions src/components/markdown/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ import breaks from 'remark-breaks';
import remarkGfm from 'remark-gfm';

const Markdown = ({ content }: { content: string }) => {
// replace \n with \n\n when it follows a sentence starting with '>'
let preserveNewlineAfterQuote = content?.replace(/(^|\n)(>[^>].*?)(\n)/gm, '$1\n$2\n\n');

// replace \n\n with \n for list items separated by two newlines
let adjustListNewlines = preserveNewlineAfterQuote?.replace(/(\n\n)([*-]|[0-9]+\.) (.+?)(?=\n\n([*-]|[0-9]+\.) )/gms, '\n$2 $3');

const customSchema = useMemo(
() => ({
...defaultSchema,
Expand Down Expand Up @@ -41,7 +35,7 @@ const Markdown = ({ content }: { content: string }) => {
return (
<span className={styles.markdown}>
<ReactMarkdown
children={adjustListNewlines}
children={content}
remarkPlugins={[excludeBlockquote, [remarkGfm, { singleTilde: false }], breaks]}
rehypePlugins={[[rehypeSanitize, customSchema]]}
components={{
Expand Down
1 change: 1 addition & 0 deletions src/components/post/label/label.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
line-height: 14px;
padding: 0 4px;
margin: 0 2px 2px 0;
text-transform: uppercase;
}

.black {
Expand Down
18 changes: 12 additions & 6 deletions src/components/post/label/label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,41 @@ import styles from './label.module.css';
export const DeletedLabel = () => {
const { t } = useTranslation();

return <span className={`${styles.stamp} ${styles.red}`}>{t('deleted').toUpperCase()}</span>;
return <span className={`${styles.stamp} ${styles.red}`}>{t('deleted')}</span>;
};

export const FailedLabel = () => {
const { t } = useTranslation();

return <span className={`${styles.stamp} ${styles.red}`}>{t('failed').toUpperCase()}</span>;
return <span className={`${styles.stamp} ${styles.red}`}>{t('failed')}</span>;
};

export const PendingLabel = () => {
const { t } = useTranslation();

return <span className={`${styles.stamp} ${styles.yellow}`}>{t('pending').toUpperCase()}</span>;
return <span className={`${styles.stamp} ${styles.yellow}`}>{t('pending')}</span>;
};

export const RemovedLabel = () => {
const { t } = useTranslation();

return <span className={`${styles.stamp} ${styles.red}`}>{t('removed').toUpperCase()}</span>;
return <span className={`${styles.stamp} ${styles.red}`}>{t('removed')}</span>;
};

export const SpoilerLabel = () => {
const { t } = useTranslation();

return <span className={`${styles.stamp} ${styles.black}`}>{t('spoiler').toUpperCase()}</span>;
return <span className={`${styles.stamp} ${styles.black}`}>{t('spoiler')}</span>;
};

export const RoleLabel = ({ role }: { role: string }) => {
const { t } = useTranslation();

return <span className={`${styles.stamp} ${styles.green}`}>{t(role).toUpperCase()}</span>;
return <span className={`${styles.stamp} ${styles.green}`}>{t(role)}</span>;
};

export const OfflineLabel = () => {
const { t } = useTranslation();

return <span className={`${styles.stamp} ${styles.red}`}>{t('offline')}</span>;
};
65 changes: 64 additions & 1 deletion src/lib/utils/challenge-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,70 @@ export const getDefaultChallengeDescription = (challengeType: string) => {
}
};

export const getDefaultOptionInputs = (challengeType: string) => {
export const getDefaultChallengeOptions = (challengeType: string) => {
switch (challengeType) {
case 'text-math':
return {
difficulty: '1',
};
case 'captcha-canvas-v3':
return {
characters: '',
height: '',
width: '',
color: '',
};
case 'fail':
return {
error: "You're not allowed to publish.",
};
case 'blacklist':
return {
blacklist: '',
error: "You're blacklisted.",
};
case 'question':
return {
question: '',
answer: '',
};
case 'evm-contract-call':
return {
chainTicker: 'eth',
address: '',
abi: '',
condition: '',
error: "Contract call response doesn't pass condition.",
};
default:
return {};
}
};

export type OptionInput = {
option: string;
label: string;
default?: string;
description: string;
placeholder?: string;
required?: boolean;
};

export type Exclude = {
postScore?: number;
postReply?: number;
firstCommentTimestamp?: number;
challenges?: number[];
post?: boolean;
reply?: boolean;
vote?: boolean;
role?: string[];
address?: string[];
rateLimit?: number;
rateLimitChallengeSuccess?: boolean;
};

export const getDefaultChallengeSettings = (challengeType: string) => {
switch (challengeType) {
case 'text-math':
return [
Expand Down
8 changes: 4 additions & 4 deletions src/lib/utils/view-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ export const isSubplebbitsVoteView = (pathname: string): boolean => {
return pathname === '/communities/vote';
};

export const isSubplebbitsVotePassedView = (pathname: string): boolean => {
return pathname === '/communities/vote/passed';
export const isSubplebbitsVotePassingView = (pathname: string): boolean => {
return pathname === '/communities/vote/passing';
};

export const isSubplebbitsVoteRejectedView = (pathname: string): boolean => {
return pathname === '/communities/vote/rejected';
export const isSubplebbitsVoteRejectingView = (pathname: string): boolean => {
return pathname === '/communities/vote/rejecting';
};
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
text-transform: lowercase;
}

.fullSettings textarea {
.JSONSettings textarea {
height: 200px;
}

Expand Down Expand Up @@ -114,13 +114,13 @@
}

.challengeOption {
font-size: 15px;
margin-top: 10px !important;
font-size: 14px;
margin-top: 10px;
}

.challengeDescription {
margin: 15px 0 15px 0;
font-size: 15px;
margin: 20px 0 0 0;
font-size: 16px;
}

.challengeOptionDescription {
Expand All @@ -137,6 +137,7 @@
width: auto !important;
outline: none;
cursor: pointer;
margin-top: 2px;
}

.challengesArray {
Expand Down
Loading