).forEach(([key, value]) => {
if (advancedProblemSettingKeys.includes(key)) {
defaultSettings[key] = value.value;
}
});
- dispatch(actions.problem.updateField({ defaultSettings: camelizeKeys(defaultSettings) }));
+
+ dispatch(actions.problem.updateField({
+ defaultSettings: camelizeKeys(defaultSettings),
+ }));
+
loadProblem({
- rawOLX, rawSettings, defaultSettings, isMarkdownEditorEnabled,
+ rawOLX,
+ rawSettings,
+ defaultSettings,
+ isMarkdownEditorEnabled,
})(dispatch);
+
+ resolve(true);
},
+
onFailure: () => {
loadProblem({
- rawOLX, rawSettings, defaultSettings: {}, isMarkdownEditorEnabled,
+ rawOLX,
+ rawSettings,
+ defaultSettings: {},
+ isMarkdownEditorEnabled,
})(dispatch);
+
+ resolve(false);
},
}));
-};
+});
export const initializeProblem = (blockValue) => (dispatch, getState) => {
const rawOLX = get(blockValue, 'data.data', '');
@@ -129,13 +151,12 @@ export const initializeProblem = (blockValue) => (dispatch, getState) => {
// So proceed with loading the problem.
// Though first we need to fake the request or else the problem type selection UI won't display:
dispatch(actions.requests.completeRequest({ requestKey: RequestKeys.fetchAdvancedSettings, response: {} }));
- dispatch(loadProblem({
+ return dispatch(loadProblem({
rawOLX, rawSettings, defaultSettings: {}, isMarkdownEditorEnabled,
}));
- } else {
- // Load the defaults (for max_attempts, etc.) from the course's advanced settings, then proceed:
- dispatch(fetchAdvancedSettings({ rawOLX, rawSettings, isMarkdownEditorEnabled }));
}
+ // Load the defaults (for max_attempts, etc.) from the course's advanced settings, then proceed:
+ return dispatch(fetchAdvancedSettings({ rawOLX, rawSettings, isMarkdownEditorEnabled }));
};
export default {
diff --git a/src/generic/block-type-utils/constants.ts b/src/generic/block-type-utils/constants.ts
index 93c1bf8ea8..f9dd23cfdb 100644
--- a/src/generic/block-type-utils/constants.ts
+++ b/src/generic/block-type-utils/constants.ts
@@ -89,13 +89,3 @@ export const COMPONENT_TYPE_STYLE_COLOR_MAP = {
collection: 'component-style-collection',
other: 'component-style-other',
};
-
-export const ICON_BORDER_STYLE_COLOR_MAP = {
- vertical: 'icon-with-border-vertical',
- unit: 'icon-with-border-vertical',
- sequential: 'icon-with-border-sequential',
- subsection: 'icon-with-border-sequential',
- chapter: 'icon-with-border-chapter',
- section: 'icon-with-border-chapter',
- other: 'icon-with-border-other',
-};
diff --git a/src/generic/block-type-utils/index.scss b/src/generic/block-type-utils/index.scss
index eed04b4b73..b6fb806085 100644
--- a/src/generic/block-type-utils/index.scss
+++ b/src/generic/block-type-utils/index.scss
@@ -1,5 +1,40 @@
+:root {
+ --content-library-component-default-color: #646464;
+ --content-library-component-default-color-light: #7E7E7E;
+ --content-library-component-default-color-light-focus: #979797;
+ --content-library-component-default-color-dark: #3E3E3E;
+ --content-library-component-primary-color: #005C9E;
+ --content-library-component-primary-color-light: #007AD1;
+ --content-library-component-primary-color-light-focus: #0597FF;
+ --content-library-component-primary-color-dark: #002F52;
+ --content-library-component-html-color: #9747FF;
+ --content-library-component-html-color-light: #B47AFF;
+ --content-library-component-html-color-light-focus: #D1ADFF;
+ --content-library-component-html-color-dark: #6C00FA;
+ --content-library-component-video-color: #358F0A;
+ --content-library-component-video-color-light: #47BF0D;
+ --content-library-component-video-color-light-focus: #58EE11;
+ --content-library-component-video-color-dark: #1B4805;
+ --content-library-collection-color: #FFCD29;
+ --content-library-collection-color-light: #FFD95C;
+ --content-library-collection-color-light-focus: #FFDF75;
+ --content-library-collection-color-dark: #DCA800;
+ --content-library-container-unit-color: #0B8E77;
+ --content-library-container-unit-color-light: #0FBD9F;
+ --content-library-container-unit-color-light-focus: #12EDC6;
+ --content-library-container-unit-color-dark: #06473C;
+ --content-library-container-subsection-color: #EA3E3E;
+ --content-library-container-subsection-color-light: #EF6C6C;
+ --content-library-container-subsection-color-light-focus: #F49A9A;
+ --content-library-container-subsection-color-dark: #C61616;
+ --content-library-container-section-color: #45009E;
+ --content-library-container-section-color-light: #5B00D1;
+ --content-library-container-section-color-light-focus: #7205FF;
+ --content-library-container-section-color-dark: #240052;
+}
+
.component-style-default {
- background-color: #005C9E;
+ background-color: var(--content-library-component-primary-color);
.pgn__icon:not(.btn-icon-before) {
color: white;
@@ -7,16 +42,16 @@
.btn-icon {
&:hover, &:active, &:focus {
- background-color: darken(#005C9E, 15%);
+ background-color: var(--content-library-component-primary-color-dark);
}
}
.btn {
- background-color: lighten(#005C9E, 10%);
+ background-color: var(--content-library-component-primary-color-light);
border: 0;
&:hover, &:active, &:focus {
- background-color: lighten(#005C9E, 20%);
+ background-color: var(--content-library-component-primary-color-light-focus);
border: 1px solid var(--pgn-color-primary-base);
margin: -1px;
}
@@ -28,7 +63,7 @@
}
.component-style-html {
- background-color: #9747FF;
+ background-color: var(--content-library-component-html-color);
.pgn__icon:not(.btn-icon-before) {
color: white;
@@ -36,16 +71,16 @@
.btn-icon {
&:hover, &:active, &:focus {
- background-color: darken(#9747FF, 15%);
+ background-color: var(--content-library-component-html-color-dark);
}
}
.btn {
- background-color: lighten(#9747FF, 10%);
+ background-color: var(--content-library-component-html-color-light);
border: 0;
&:hover, &:active, &:focus {
- background-color: lighten(#9747FF, 20%);
+ background-color: var(--content-library-component-html-color-light-focus);
border: 1px solid var(--pgn-color-primary-base);
margin: -1px;
}
@@ -57,7 +92,7 @@
}
.component-style-collection {
- background-color: #FFCD29;
+ background-color: var(--content-library-collection-color);
.pgn__icon:not(.btn-icon-before) {
color: black;
@@ -65,16 +100,16 @@
.btn-icon {
&:hover, &:active, &:focus {
- background-color: darken(#FFCD29, 15%);
+ background-color: var(--content-library-collection-color-dark);
}
}
.btn {
- background-color: lighten(#FFCD29, 10%);
+ background-color: var(--content-library-collection-color-light);
border: 0;
&:hover, &:active, &:focus {
- background-color: lighten(#FFCD29, 20%);
+ background-color: var(--content-library-collection-color-light-focus);
border: 1px solid var(--pgn-color-primary-base);
margin: -1px;
}
@@ -86,7 +121,7 @@
}
.component-style-video {
- background-color: #358F0A;
+ background-color: var(--content-library-component-video-color);
.pgn__icon:not(.btn-icon-before) {
color: white;
@@ -94,16 +129,16 @@
.btn-icon {
&:hover, &:active, &:focus {
- background-color: darken(#358F0A, 15%);
+ background-color: var(--content-library-component-video-color-dark);
}
}
.btn {
- background-color: lighten(#358F0A, 10%);
+ background-color: var(--content-library-component-video-color-light);
border: 0;
&:hover, &:active, &:focus {
- background-color: lighten(#358F0A, 20%);
+ background-color: var(--content-library-component-video-color-light-focus);
border: 1px solid var(--pgn-color-primary-base);
margin: -1px;
}
@@ -115,7 +150,7 @@
}
.component-style-vertical {
- background-color: #0B8E77;
+ background-color: var(--content-library-container-unit-color);
.pgn__icon:not(.btn-icon-before) {
color: white;
@@ -123,16 +158,16 @@
.btn-icon {
&:hover, &:active, &:focus {
- background-color: darken(#0B8E77, 15%);
+ background-color: var(--content-library-container-unit-color-dark);
}
}
.btn {
- background-color: lighten(#0B8E77, 10%);
+ background-color: var(--content-library-container-unit-color-light);
border: 0;
&:hover, &:active, &:focus {
- background-color: lighten(#0B8E77, 20%);
+ background-color: var(--content-library-container-unit-color-light-focus);
border: 1px solid var(--pgn-color-primary-base);
margin: -1px;
}
@@ -144,7 +179,7 @@
}
.component-style-sequential {
- background-color: #EA3E3E;
+ background-color: var(--content-library-container-subsection-color);
.pgn__icon:not(.btn-icon-before) {
color: white;
@@ -152,16 +187,16 @@
.btn-icon {
&:hover, &:active, &:focus {
- background-color: darken(#EA3E3E, 15%);
+ background-color: var(--content-library-container-subsection-color-dark);
}
}
.btn {
- background-color: lighten(#EA3E3E, 10%);
+ background-color: var(--content-library-container-subsection-color-light);
border: 0;
&:hover, &:active, &:focus {
- background-color: lighten(#EA3E3E, 20%);
+ background-color: var(--content-library-container-subsection-color-light-focus);
border: 1px solid var(--pgn-color-primary-base);
margin: -1px;
}
@@ -173,7 +208,7 @@
}
.component-style-chapter {
- background-color: #45009E;
+ background-color: var(--content-library-container-section-color);
.pgn__icon:not(.btn-icon-before) {
color: white;
@@ -181,17 +216,17 @@
.btn-icon {
&:hover, &:active, &:focus {
- background-color: darken(#45009E, 15%);
+ background-color: var(--content-library-container-section-color-dark);
}
}
.btn {
- background-color: lighten(#45009E, 10%);
+ background-color: var(--content-library-container-section-color-light);
border: 0;
color: white;
&:hover, &:active, &:focus {
- background-color: lighten(#45009E, 20%);
+ background-color: var(--content-library-container-section-color-light-focus);
border: 1px solid var(--pgn-color-primary-base);
margin: -1px;
}
@@ -203,7 +238,7 @@
}
.component-style-other {
- background-color: #646464;
+ background-color: var(--content-library-component-default-color);
.pgn__icon:not(.btn-icon-before) {
color: white;
@@ -211,16 +246,16 @@
.btn-icon {
&:hover, &:active, &:focus {
- background-color: darken(#646464, 15%);
+ background-color: var(--content-library-component-default-color-dark);
}
}
.btn {
- background-color: lighten(#646464, 10%);
+ background-color: var(--content-library-component-default-color-light);
border: 0;
&:hover, &:active, &:focus {
- background-color: lighten(#646464, 20%);
+ background-color: var(--content-library-component-default-color-light-focus);
border: 1px solid var(--pgn-color-primary-base);
margin: -1px;
}
@@ -231,38 +266,61 @@
}
}
-.icon-with-border-chapter {
+.icon-with-border {
background-color: white;
- border: 1px solid #45009E;
+ border: 1px solid var(--content-library-component-default-color);
.pgn__icon {
- color: #45009E;
+ color: var(--content-library-component-default-color);
}
}
-.icon-with-border-sequential {
- background-color: white;
- border: 1px solid #EA3E3E;
+.icon-with-border-problem,
+.icon-with-border-drag-and-drop-v2,
+.icon-with-border-openassessment {
+ border: 1px solid var(--content-library-component-primary-color);
.pgn__icon {
- color: #EA3E3E;
+ color: var(--content-library-component-primary-color);
}
}
-.icon-with-border-vertical {
- background-color: white;
- border: 1px solid #0B8E77;
+.icon-with-border-chapter {
+ border: 1px solid var(--content-library-container-section-color);
.pgn__icon {
- color: #0B8E77;
+ color: var(--content-library-container-section-color);
}
}
-.icon-with-border-default {
- background-color: white;
- border: 1px solid #005C9E;
+.icon-with-border-sequential {
+ border: 1px solid var(--content-library-container-subsection-color);
+
+ .pgn__icon {
+ color: var(--content-library-container-subsection-color);
+ }
+}
+
+.icon-with-border-vertical {
+ border: 1px solid var(--content-library-container-unit-color);
+
+ .pgn__icon {
+ color: var(--content-library-container-unit-color);
+ }
+}
+
+.icon-with-border-html {
+ border: 1px solid var(--content-library-component-html-color);
+
+ .pgn__icon {
+ color: var(--content-library-component-html-color);
+ }
+}
+
+.icon-with-border-video {
+ border: 1px solid var(--content-library-component-video-color);
.pgn__icon {
- color: #005C9E;
+ color: var(--content-library-component-video-color);
}
}
diff --git a/src/generic/block-type-utils/index.tsx b/src/generic/block-type-utils/index.tsx
index 103f90c7ff..a4e2ce4b6f 100644
--- a/src/generic/block-type-utils/index.tsx
+++ b/src/generic/block-type-utils/index.tsx
@@ -6,7 +6,6 @@ import {
COMPONENT_TYPE_ICON_MAP,
STRUCTURAL_TYPE_ICONS,
COMPONENT_TYPE_STYLE_COLOR_MAP,
- ICON_BORDER_STYLE_COLOR_MAP,
} from './constants';
import messages from './messages';
@@ -19,10 +18,6 @@ export function getComponentStyleColor(blockType: string): string {
return COMPONENT_TYPE_STYLE_COLOR_MAP[blockType] ?? COMPONENT_TYPE_STYLE_COLOR_MAP.other;
}
-export function getIconBorderStyleColor(blockType: string): string {
- return ICON_BORDER_STYLE_COLOR_MAP[blockType] ?? ICON_BORDER_STYLE_COLOR_MAP.other;
-}
-
interface ComponentIconProps {
blockType: string;
iconTitle: string;
diff --git a/src/generic/sidebar/BlockCardButton.tsx b/src/generic/sidebar/BlockCardButton.tsx
new file mode 100644
index 0000000000..569fdf0ac9
--- /dev/null
+++ b/src/generic/sidebar/BlockCardButton.tsx
@@ -0,0 +1,78 @@
+import React from 'react';
+import {
+ Button, Chip, Collapsible, Icon, Stack,
+} from '@openedx/paragon';
+import { getItemIcon } from '../block-type-utils';
+
+export type BlockTemplate = {
+ displayName: string;
+ boilerplateName: string;
+};
+
+export interface BlockCardButtonProps {
+ name: string;
+ blockType: string;
+ onClick: () => void;
+ disabled?: boolean;
+ templates?: BlockTemplate[];
+ onClickTemplate?: (boilerplateName: string) => void;
+ actionIcon?: React.ReactElement;
+}
+
+/**
+ * Renders a Card button with icon, name and templates of a block type
+ */
+export const BlockCardButton = ({
+ name,
+ blockType,
+ onClick,
+ templates,
+ disabled = false,
+ onClickTemplate,
+ actionIcon,
+}: BlockCardButtonProps) => {
+ const titleComponent = (
+
+
+
+
+
+ {name}
+
+
+ );
+
+ if (templates?.length) {
+ return (
+
+
+
+ {templates.map((template) => (
+ onClickTemplate?.(template.boilerplateName)}>
+ {template.displayName}
+
+ ))}
+
+
+
+ );
+ }
+
+ return (
+
+ );
+};