@soul-refiner/design-system 1.1.11 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,37 +14,15 @@ export declare const BUTTON_SUBSCRIBE = "button-subscribe";
14
14
  export declare const COLORS: string[];
15
15
  export declare const PLACEHOLDER = "This is a placeholder";
16
16
  export declare const DEFAULT_CONTENT: ({
17
- type: string;
18
17
  children: {
19
18
  text: string;
20
- bold: boolean;
21
19
  }[];
22
- align?: undefined;
23
- url?: undefined;
24
- } | {
20
+ questionAnswerId: string;
25
21
  type: string;
26
- children: ({
27
- text: string;
28
- italic?: undefined;
29
- } | {
30
- text: string;
31
- italic: boolean;
32
- })[];
33
- align?: undefined;
34
- url?: undefined;
35
22
  } | {
36
- type: string;
37
- align: string;
38
23
  children: {
39
24
  text: string;
40
- bold: boolean;
41
25
  }[];
42
- url?: undefined;
43
- } | {
44
26
  type: string;
45
- url: string;
46
- children: {
47
- text: string;
48
- }[];
49
- align?: undefined;
27
+ questionAnswerId?: undefined;
50
28
  })[];
@@ -9,12 +9,6 @@ export const ELEMENT_POLL = 'poll';
9
9
  export const ELEMENT_QA = 'q-n-a';
10
10
  export const ELEMENT_RECIPE = 'recipe';
11
11
  export const ELEMENT_VIDEO = 'video';
12
- // export const BUTTON_COMMENT = 'button-comment';
13
- // export const BUTTON_GIFT_SUBSCRIPTION = 'button-gift-subscription';
14
- // export const BUTTON_SHARE = 'button-share';
15
- // export const BUTTON_SHARE_PAGE = 'button-share-page';
16
- // export const BUTTON_SIGNUP = 'signup';
17
- // export const BUTTON_SPECIAL_OFFER = 'button-special-offer';
18
12
  export const BUTTON_LINK = 'button-link';
19
13
  export const BUTTON_SUBSCRIBE = 'button-subscribe';
20
14
  export const COLORS = [
@@ -29,105 +23,20 @@ export const COLORS = [
29
23
  export const PLACEHOLDER = 'This is a placeholder';
30
24
  export const DEFAULT_CONTENT = [
31
25
  {
32
- type: 'h1',
33
26
  children: [
34
27
  {
35
- text: 'Module 1: The Warrior Identity',
36
- bold: true,
28
+ text: 'What are you struggling with today and how is it affecting the people you love? This is a longer sentence to see what it looks like.',
37
29
  },
38
30
  ],
31
+ questionAnswerId: 'q-n-a-ac0396ed-62ed-4a30-ba12-98f4fa2d364c',
32
+ type: 'q-n-a',
39
33
  },
40
34
  {
41
- type: 'p',
42
- children: [
43
- {
44
- text: 'Welcome to Warpath. You’re about to embark on a journey towards lifelong healing, freedom and victory. This is a season of training. It’s sanctification on steroids, not for the faint-hearted, but for those who truly desire to live the rest of their lives for Jesus. No reserves, no retreats, no regrets.',
45
- },
46
- {
47
- text: ' What was once your deepest, darkest secret will now become the word of your testimony that heals and liberates others.',
48
- },
49
- ],
50
- },
51
- {
52
- type: 'p',
53
- children: [
54
- {
55
- text: 'In this new season, God is calling you up. He’s calling you to a higher level, a place where you’re no longer part of the problem but are becoming a part of the solution.',
56
- },
57
- {
58
- text: '',
59
- },
60
- ],
61
- },
62
- {
63
- type: 'blockquote',
64
- children: [
65
- {
66
- text: '"Warpath isn’t about just winning for you; that’s the beginning. Warpath is about you taking the battle and winning for others so they can have their families, and their marriages, and their destinies." \n— ',
67
- },
68
- {
69
- text: 'Dr. Doug Weiss',
70
- italic: true,
71
- },
72
- ],
73
- },
74
- // {
75
- // type: 'hr',
76
- // children: [
77
- // {
78
- // text: '',
79
- // },
80
- // ],
81
- // },
82
- {
83
- type: 'h3',
84
- align: 'center',
85
- children: [
86
- {
87
- text: 'THE WARRIOR IDENTITY',
88
- bold: true,
89
- },
90
- ],
91
- },
92
- // {
93
- // type: 'hr',
94
- // children: [
95
- // {
96
- // text: '',
97
- // },
98
- // ],
99
- // },
100
- {
101
- type: 'img',
102
- url: 'https://source.unsplash.com/1600x900/?christian',
103
35
  children: [
104
36
  {
105
37
  text: '',
106
38
  },
107
39
  ],
108
- },
109
- {
110
40
  type: 'p',
111
- children: [
112
- {
113
- text: 'Identity: You will have to grasp your true identity in Christ. You cannot look at this as a “what”, but instead about a “who”. We must become more like Christ, because He is a warrior.',
114
- },
115
- ],
116
- },
117
- {
118
- type: 'p',
119
- children: [
120
- {
121
- text: 'A different DNA: As a warrior, your spiritual genetic code will be different from those who haven’t tasted the victory and grace you’ve experienced from this battle. You’ve experienced truth as a person: Jesus; and it has forever changed you. You’ve been set apart as a “fighting man”, no longer a civilian idly consumed by the cares of this world, but a warrior who’s passionate about the Kingdom and craving some sweet revenge.',
122
- },
123
- ],
124
- },
125
- {
126
- type: 'p',
127
- children: [
128
- {
129
- text: '',
130
- },
131
- ],
132
41
  },
133
42
  ];
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export declare const EditorContext: React.Context<{
3
+ commentInputLoader: (props: {
4
+ questionAnswerId: string;
5
+ }) => React.ReactElement;
6
+ commentLoader: (props: {
7
+ questionAnswerId: string;
8
+ }) => React.ReactElement;
9
+ }>;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export const EditorContext = React.createContext({
3
+ commentInputLoader: () => React.createElement(React.Fragment, null),
4
+ commentLoader: () => React.createElement(React.Fragment, null),
5
+ });
@@ -1,6 +1,12 @@
1
1
  import React from 'react';
2
2
  import { TElement } from '@udecode/plate';
3
3
  export interface EditorProps {
4
+ commentInputLoader: (props: {
5
+ questionAnswerId: string;
6
+ }) => React.ReactElement;
7
+ commentLoader: (props: {
8
+ questionAnswerId: string;
9
+ }) => React.ReactElement;
4
10
  communityName: string;
5
11
  editable: boolean;
6
12
  handleUploadImage: (files: FileList) => Promise<string>;
@@ -8,4 +14,4 @@ export interface EditorProps {
8
14
  previousContent?: TElement[];
9
15
  }
10
16
  export type EditorContent = TElement;
11
- export declare const Editor: ({ editable, handleUploadImage, onChange, previousContent, }: EditorProps) => React.JSX.Element;
17
+ export declare const Editor: ({ commentInputLoader, commentLoader, editable, handleUploadImage, onChange, previousContent, }: EditorProps) => React.JSX.Element;
@@ -3,17 +3,19 @@ import React from 'react';
3
3
  import styled from 'styled-components';
4
4
  import { createPlugins, Plate, PlateContent } from '@udecode/plate';
5
5
  import { DEFAULT_CONTENT, PLACEHOLDER } from './constants';
6
+ import { EditorContext } from './context';
6
7
  import { EditorBar } from './navbar';
7
8
  import { plateUI } from './plate';
8
9
  import { blocks, inline, marks, utils } from './plugins';
9
10
  const plugins = createPlugins([...blocks, ...inline, ...marks, ...utils], {
10
11
  components: plateUI,
11
12
  });
12
- export const Editor = ({ editable, handleUploadImage, onChange, previousContent = DEFAULT_CONTENT, }) => {
13
- return (React.createElement(Plate, { id: "main", initialValue: previousContent, onChange: onChange, plugins: plugins },
14
- React.createElement(Wrapper, null,
15
- editable && React.createElement(EditorBar, { handleUploadImage: handleUploadImage }),
16
- React.createElement(PlateContent, { id: "main", autoFocus: true, placeholder: PLACEHOLDER, readOnly: !editable, spellCheck: true }))));
13
+ export const Editor = ({ commentInputLoader, commentLoader, editable, handleUploadImage, onChange, previousContent = DEFAULT_CONTENT, }) => {
14
+ return (React.createElement(EditorContext.Provider, { value: { commentInputLoader, commentLoader } },
15
+ React.createElement(Plate, { id: "main", initialValue: previousContent, onChange: onChange, plugins: plugins },
16
+ React.createElement(Wrapper, null,
17
+ editable && React.createElement(EditorBar, { handleUploadImage: handleUploadImage }),
18
+ React.createElement(PlateContent, { id: "main", autoFocus: true, placeholder: PLACEHOLDER, readOnly: !editable, spellCheck: true })))));
17
19
  };
18
20
  const Wrapper = styled.div `
19
21
  * {
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * PLUGINS
3
3
  */
4
- import { createBlockquotePlugin, createCodeBlockPlugin, createHeadingPlugin, createHorizontalRulePlugin, createIndentListPlugin, createImagePlugin, createTextIndentPlugin, createListPlugin, createMediaEmbedPlugin, createResetNodePlugin, createTablePlugin, createBoldPlugin, createCodePlugin, createFontBackgroundColorPlugin, createFontSizePlugin, createFontFamilyPlugin, createItalicPlugin, createStrikethroughPlugin, createSubscriptPlugin, createSuperscriptPlugin, createUnderlinePlugin, createAlignPlugin, createIndentPlugin, createLineHeightPlugin, createLinkPlugin, createExitBreakPlugin, createHistoryPlugin, createSelectOnBackspacePlugin, createSoftBreakPlugin, } from '@udecode/plate';
4
+ import { createBlockquotePlugin, createCodeBlockPlugin, createHeadingPlugin, createHorizontalRulePlugin, createIndentListPlugin, createImagePlugin, createTextIndentPlugin, createListPlugin, createMediaEmbedPlugin, createResetNodePlugin, createTablePlugin, createBoldPlugin, createCodePlugin, createFontBackgroundColorPlugin, createFontSizePlugin, createFontFamilyPlugin, createItalicPlugin, createStrikethroughPlugin, createSubscriptPlugin, createSuperscriptPlugin, createUnderlinePlugin, createAlignPlugin, createIndentPlugin, createLineHeightPlugin, createExitBreakPlugin, createHistoryPlugin, createSelectOnBackspacePlugin, createSoftBreakPlugin, } from '@udecode/plate';
5
+ import { createLinkPlugin } from '@udecode/plate-link';
5
6
  import { createButtonsPlugin } from './buttons';
6
7
  import { exitBreakPlugin } from './exitBreak';
7
8
  import { resetBlockTypePlugin } from './resetBlockType';
@@ -9,6 +10,7 @@ import { selectOnBackspace } from './selectOnBackspace';
9
10
  import { softBreakPlugin } from './softBreak';
10
11
  import { createParagraphPlugin, createHOnePlugin, createHTwoPlugin, createHThreePlugin, createHFourPlugin, createHFivePlugin, createHSixPlugin, } from './text';
11
12
  import { LinkFloatingMenu } from './link';
13
+ import { createQAPlugin } from './qa';
12
14
  /**
13
15
  * ELEMENT TYPES
14
16
  */
@@ -28,6 +30,7 @@ export const blocks = [
28
30
  disableEmbedInsert: true,
29
31
  },
30
32
  }),
33
+ createQAPlugin(),
31
34
  createTextIndentPlugin(),
32
35
  createIndentListPlugin({
33
36
  inject: {
@@ -95,7 +98,7 @@ export const inline = [
95
98
  }),
96
99
  createLineHeightPlugin(),
97
100
  createLinkPlugin({
98
- renderAfterEditable: LinkFloatingMenu,
101
+ renderBeforeEditable: LinkFloatingMenu,
99
102
  }),
100
103
  ];
101
104
  export const utils = [
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { PlateElementProps } from '@udecode/plate';
3
+ export declare const QuestionAnswerElement: React.ForwardRefExoticComponent<Omit<PlateElementProps, "ref"> & React.RefAttributes<any>>;
4
+ export declare const createQAPlugin: <OP = import("@udecode/utils").AnyObject, OV extends import("@udecode/slate").Value = import("@udecode/slate").Value, OE extends import("@udecode/plate-core").PlateEditor<OV> = import("@udecode/plate-core").PlateEditor<OV>>(override?: Partial<import("@udecode/plate-core").PlatePlugin<import("@udecode/plate-core").NoInfer<OP>, OV, OE>> | undefined, overrideByKey?: import("@udecode/plate-core").OverrideByKey<OV, OE> | undefined) => import("@udecode/plate-core").PlatePlugin<import("@udecode/plate-core").NoInfer<OP>, OV, OE>;
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import { createPluginFactory, PlateElement, } from '@udecode/plate';
3
+ import styled from 'styled-components';
4
+ import { ELEMENT_QA } from '../constants';
5
+ import { EditorContext } from '../context';
6
+ import { Button } from '../../actions';
7
+ import { Box } from '../../atoms/box';
8
+ import { H } from '../../atoms/typography';
9
+ import { ChevronDown } from '../../../icons/arrow/chevron_down';
10
+ import { ChevronUp } from '../../../icons/arrow/chevron_up';
11
+ export const QuestionAnswerElement = React.forwardRef(({ children, element, ...props }, ref) => {
12
+ const { questionAnswerId } = element;
13
+ const { commentInputLoader: CommentInput, commentLoader: Comments } = React.useContext(EditorContext);
14
+ const [showAnswers, setShowAnswers] = React.useState(false);
15
+ return (React.createElement(PlateElement, { asChild: true, element: element, ref: ref, ...props },
16
+ React.createElement(Box, { "$dir": "column", "$gap": 8 },
17
+ React.createElement(Question, null,
18
+ React.createElement(H, { as: "p", "$fontSize": 18, "$lineHeight": 26, "$mediumBold": true }, children)),
19
+ React.createElement(Box, { "$dir": "column", "$gap": 24, "$padding": 24 },
20
+ React.createElement(Button, { as: "div", icon: showAnswers ? (React.createElement(ChevronUp, { color: "grey-3" })) : (React.createElement(ChevronDown, { color: "grey-3" })), onClick: () => setShowAnswers((prev) => !prev), size: "small", sx: `
21
+ width: fit-content;
22
+ flex-direction: row-reverse;
23
+ color: var(--color-grey-5);
24
+ &:not(:hover) svg {
25
+ fill: var(--color-grey-3);
26
+ }
27
+ `, type: "text", ...{ contentEditable: false } }, showAnswers ? 'Hide answers' : 'Show answers'),
28
+ showAnswers && React.createElement(Comments, { questionAnswerId: questionAnswerId }),
29
+ React.createElement(CommentInput, { questionAnswerId: questionAnswerId })))));
30
+ });
31
+ const Question = styled.div `
32
+ padding: 16px;
33
+ border-left: 8px solid var(--color-hue-blue-1);
34
+ border-radius: 8px;
35
+ background-color: var(--color-hue-blue-3);
36
+ `;
37
+ export const createQAPlugin = createPluginFactory({
38
+ key: ELEMENT_QA,
39
+ type: ELEMENT_QA,
40
+ isElement: true,
41
+ component: QuestionAnswerElement,
42
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soul-refiner/design-system",
3
- "version": "1.1.11",
3
+ "version": "1.2.1",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "publishConfig": {