mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 23:46:03 +01:00
tweak(web): adjust markdown heading margins (#393)
* tweak(web): components for markdown headings Fixed nomenclature and set as default export. * fix(ui): temp remove MarkdownComponents file * fix(ui): return MarkdownComponents file
This commit is contained in:
10
web/src/config/MarkdownComponents.tsx
Normal file
10
web/src/config/MarkdownComponents.tsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { Title } from '@mantine/core';
|
||||||
|
import { Components } from 'react-markdown';
|
||||||
|
|
||||||
|
const MarkdownComponents: Components = {
|
||||||
|
h1: ({ node, ...props }) => <Title {...props} />,
|
||||||
|
h2: ({ node, ...props }) => <Title order={2} {...props} />,
|
||||||
|
h3: ({ node, ...props }) => <Title order={3} {...props} />,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default MarkdownComponents;
|
||||||
@@ -6,6 +6,7 @@ import { fetchNui } from '../../utils/fetchNui';
|
|||||||
import { useLocales } from '../../providers/LocaleProvider';
|
import { useLocales } from '../../providers/LocaleProvider';
|
||||||
import remarkGfm from 'remark-gfm';
|
import remarkGfm from 'remark-gfm';
|
||||||
import type { AlertProps } from '../../typings';
|
import type { AlertProps } from '../../typings';
|
||||||
|
import MarkdownComponents from '../../config/MarkdownComponents';
|
||||||
|
|
||||||
const AlertDialog: React.FC = () => {
|
const AlertDialog: React.FC = () => {
|
||||||
const { locale } = useLocales();
|
const { locale } = useLocales();
|
||||||
@@ -46,12 +47,13 @@ const AlertDialog: React.FC = () => {
|
|||||||
overlayOpacity={0.5}
|
overlayOpacity={0.5}
|
||||||
exitTransitionDuration={150}
|
exitTransitionDuration={150}
|
||||||
transition="fade"
|
transition="fade"
|
||||||
title={<ReactMarkdown>{dialogData.header}</ReactMarkdown>}
|
title={<ReactMarkdown components={MarkdownComponents}>{dialogData.header}</ReactMarkdown>}
|
||||||
>
|
>
|
||||||
<Stack>
|
<Stack>
|
||||||
<ReactMarkdown
|
<ReactMarkdown
|
||||||
remarkPlugins={[remarkGfm]}
|
remarkPlugins={[remarkGfm]}
|
||||||
components={{
|
components={{
|
||||||
|
...MarkdownComponents,
|
||||||
img: ({ ...props }) => <img style={{ maxWidth: '100%', maxHeight: '100%' }} {...props} />,
|
img: ({ ...props }) => <img style={{ maxWidth: '100%', maxHeight: '100%' }} {...props} />,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { fetchNui } from '../../../utils/fetchNui';
|
|||||||
import ReactMarkdown from 'react-markdown';
|
import ReactMarkdown from 'react-markdown';
|
||||||
import HeaderButton from './components/HeaderButton';
|
import HeaderButton from './components/HeaderButton';
|
||||||
import ScaleFade from '../../../transitions/ScaleFade';
|
import ScaleFade from '../../../transitions/ScaleFade';
|
||||||
|
import MarkdownComponents from '../../../config/MarkdownComponents';
|
||||||
|
|
||||||
const openMenu = (id: string | undefined) => {
|
const openMenu = (id: string | undefined) => {
|
||||||
fetchNui<ContextMenuProps>('openContext', { id: id, back: true });
|
fetchNui<ContextMenuProps>('openContext', { id: id, back: true });
|
||||||
@@ -92,7 +93,7 @@ const ContextMenu: React.FC = () => {
|
|||||||
)}
|
)}
|
||||||
<Box className={classes.titleContainer}>
|
<Box className={classes.titleContainer}>
|
||||||
<Text className={classes.titleText}>
|
<Text className={classes.titleText}>
|
||||||
<ReactMarkdown>{contextMenu.title}</ReactMarkdown>
|
<ReactMarkdown components={MarkdownComponents}>{contextMenu.title}</ReactMarkdown>
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
<HeaderButton icon="xmark" canClose={contextMenu.canClose} iconSize={18} handleClick={closeContext} />
|
<HeaderButton icon="xmark" canClose={contextMenu.canClose} iconSize={18} handleClick={closeContext} />
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { Option, ContextMenuProps } from '../../../../typings';
|
|||||||
import { fetchNui } from '../../../../utils/fetchNui';
|
import { fetchNui } from '../../../../utils/fetchNui';
|
||||||
import { isIconUrl } from '../../../../utils/isIconUrl';
|
import { isIconUrl } from '../../../../utils/isIconUrl';
|
||||||
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
||||||
|
import MarkdownComponents from '../../../../config/MarkdownComponents';
|
||||||
|
|
||||||
const openMenu = (id: string | undefined) => {
|
const openMenu = (id: string | undefined) => {
|
||||||
fetchNui<ContextMenuProps>('openContext', { id: id, back: false });
|
fetchNui<ContextMenuProps>('openContext', { id: id, back: false });
|
||||||
@@ -108,12 +109,12 @@ const ContextButton: React.FC<{
|
|||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
<Text className={classes.buttonTitleText}>
|
<Text className={classes.buttonTitleText}>
|
||||||
<ReactMarkdown>{button.title || buttonKey}</ReactMarkdown>
|
<ReactMarkdown components={MarkdownComponents}>{button.title || buttonKey}</ReactMarkdown>
|
||||||
</Text>
|
</Text>
|
||||||
</Group>
|
</Group>
|
||||||
{button.description && (
|
{button.description && (
|
||||||
<Text className={classes.description}>
|
<Text className={classes.description}>
|
||||||
<ReactMarkdown>{button.description}</ReactMarkdown>
|
<ReactMarkdown components={MarkdownComponents}>{button.description}</ReactMarkdown>
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
{button.progress !== undefined && (
|
{button.progress !== undefined && (
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import ReactMarkdown from 'react-markdown';
|
|||||||
import { Avatar, createStyles, Group, Stack, Box, Text, keyframes, Sx } from '@mantine/core';
|
import { Avatar, createStyles, Group, Stack, Box, Text, keyframes, Sx } from '@mantine/core';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import type { NotificationProps } from '../../typings';
|
import type { NotificationProps } from '../../typings';
|
||||||
|
import MarkdownComponents from '../../config/MarkdownComponents';
|
||||||
|
|
||||||
const useStyles = createStyles((theme) => ({
|
const useStyles = createStyles((theme) => ({
|
||||||
container: {
|
container: {
|
||||||
@@ -181,7 +182,10 @@ const Notifications: React.FC = () => {
|
|||||||
<Stack spacing={0}>
|
<Stack spacing={0}>
|
||||||
{data.title && <Text className={classes.title}>{data.title}</Text>}
|
{data.title && <Text className={classes.title}>{data.title}</Text>}
|
||||||
{data.description && (
|
{data.description && (
|
||||||
<ReactMarkdown className={`${!data.title ? classes.descriptionOnly : classes.description} description`}>
|
<ReactMarkdown
|
||||||
|
components={MarkdownComponents}
|
||||||
|
className={`${!data.title ? classes.descriptionOnly : classes.description} description`}
|
||||||
|
>
|
||||||
{data.description}
|
{data.description}
|
||||||
</ReactMarkdown>
|
</ReactMarkdown>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|||||||
import ScaleFade from '../../transitions/ScaleFade';
|
import ScaleFade from '../../transitions/ScaleFade';
|
||||||
import remarkGfm from 'remark-gfm';
|
import remarkGfm from 'remark-gfm';
|
||||||
import type { TextUiProps, TextUiPosition } from '../../typings';
|
import type { TextUiProps, TextUiPosition } from '../../typings';
|
||||||
|
import MarkdownComponents from '../../config/MarkdownComponents';
|
||||||
|
|
||||||
const useStyles = createStyles((theme, params: { position?: TextUiPosition }) => ({
|
const useStyles = createStyles((theme, params: { position?: TextUiPosition }) => ({
|
||||||
wrapper: {
|
wrapper: {
|
||||||
@@ -52,7 +53,9 @@ const TextUI: React.FC = () => {
|
|||||||
<Box style={data.style} className={classes.container}>
|
<Box style={data.style} className={classes.container}>
|
||||||
<Group spacing={12}>
|
<Group spacing={12}>
|
||||||
{data.icon && <FontAwesomeIcon icon={data.icon} fixedWidth size="lg" style={{ color: data.iconColor }} />}
|
{data.icon && <FontAwesomeIcon icon={data.icon} fixedWidth size="lg" style={{ color: data.iconColor }} />}
|
||||||
<ReactMarkdown remarkPlugins={[remarkGfm]}>{data.text}</ReactMarkdown>
|
<ReactMarkdown components={MarkdownComponents} remarkPlugins={[remarkGfm]}>
|
||||||
|
{data.text}
|
||||||
|
</ReactMarkdown>
|
||||||
</Group>
|
</Group>
|
||||||
</Box>
|
</Box>
|
||||||
</ScaleFade>
|
</ScaleFade>
|
||||||
|
|||||||
Reference in New Issue
Block a user