@vonaffenfels/slate-editor 1.0.70 → 1.0.72

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vonaffenfels/slate-editor",
3
- "version": "1.0.70",
3
+ "version": "1.0.72",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -71,7 +71,7 @@
71
71
  "cssnano": "^5.0.1",
72
72
  "escape-html": "^1.0.3"
73
73
  },
74
- "gitHead": "52dd9f4cd9125cc053694577cd2ac9d1bf0e9de3",
74
+ "gitHead": "4ea4a78911a1476352df5de28932c291bcc4770f",
75
75
  "publishConfig": {
76
76
  "access": "public"
77
77
  }
@@ -12,8 +12,11 @@ export const CollapsableMenu = ({
12
12
  props: {
13
13
  ...child.props,
14
14
  onClick: () => {
15
- child.props.onClick();
16
- setCollapsed(true);
15
+ if (child.props.onClick) {
16
+ child.props.onClick();
17
+
18
+ setCollapsed(true);
19
+ }
17
20
  },
18
21
  },
19
22
  }));
@@ -3,7 +3,7 @@ import React, {
3
3
  } from "react";
4
4
  import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
5
5
  import {
6
- faCog, faArrowUp, faArrowDown, faTimes, faCompress,
6
+ faDesktop, faMobile, faTablet,
7
7
  } from "@fortawesome/free-solid-svg-icons";
8
8
  import {Storybook} from "../Storybook";
9
9
  import {Transforms} from "slate";
@@ -121,7 +121,16 @@ const StorybookNodeComponent = ({
121
121
  "storybook-element-float-right": element?.attributes?.float === "right",
122
122
  })}>
123
123
  <span className={classNames({"storybook-element-component": true})}>
124
- <span className="storybook-element-component-overlay" title="Klicken, um das Element zu konfigurieren" onClick={onEditClick}>Klicken, um das Element zu konfigurieren</span>
124
+ <span className="storybook-element-component-overlay" title="Klicken, um das Element zu konfigurieren" onClick={onEditClick}>
125
+ <div className="absolute right-0 top-0 m-2">
126
+ <FontAwesomeIcon
127
+ icon={faDesktop}
128
+ color={element?.attributes?.hideOnDesktop ? "lightgray" : "black"}
129
+ className="mr-2" />
130
+ <FontAwesomeIcon icon={faTablet} color={element?.attributes?.hideOnTablet ? "lightgray" : "black"} className="mr-2" />
131
+ <FontAwesomeIcon icon={faMobile} color={element?.attributes?.hideOnSmartphone ? "lightgray" : "black"} />
132
+ </div>
133
+ Klicken, um das Element zu konfigurieren</span>
125
134
  <div onClick={onEditClick}>
126
135
  <StorybookDisplay
127
136
  {...element.attributes}
@@ -157,6 +157,9 @@ export function Serializer({
157
157
  "mb-16": props?.attributes?.margin?.bottom,
158
158
  "ml-16": props?.attributes?.margin?.left,
159
159
  "justify-center": props?.attributes?.justifyCenter,
160
+ "lg:!hidden": props?.attributes?.hideOnDesktop,
161
+ "sm:max-lg:!hidden": props?.attributes?.hideOnTablet,
162
+ "max-sm:!hidden": props?.attributes?.hideOnSmartphone,
160
163
  [typeProps.classNameSite + " site-width"]: !isInSlot && (props.attributes?.width === "site" || props.attributes?.width === "full"),
161
164
  [typeProps.classNameArticle + " article-width"]: !isInSlot && (props.attributes?.width === "article" || !props.attributes?.width),
162
165
  })}
@@ -4,6 +4,7 @@ import {reduceContentfulResponse} from "../util/reduceContentfulResponse";
4
4
  import {
5
5
  Asset, AssetList,
6
6
  } from "./AssetList";
7
+ import {Switch} from "./Switch";
7
8
 
8
9
  export const SidebarEditorField = ({
9
10
  field,
@@ -97,13 +98,12 @@ export const SidebarEditorField = ({
97
98
  }}/>;
98
99
  case "boolean":
99
100
  return (
100
- <div>
101
- <input
102
- id={fieldKey}
101
+ <div className="flex items-center">
102
+ <Switch
103
103
  type="checkbox"
104
- checked={value}
105
- onChange={e => onChange(fieldKey, e.target.checked)}/>
106
- <label htmlFor={fieldKey}>{value ? "Ja" : "Nein"}</label>
104
+ value={value}
105
+ label={value ? "Ja" : "Nein"}
106
+ onClick={() => onChange(fieldKey, !value)}/>
107
107
  </div>
108
108
  );
109
109
  case "select":
@@ -0,0 +1,35 @@
1
+ import React from "react";
2
+ import classNames from "classnames";
3
+
4
+ export const Switch = ({
5
+ value,
6
+ onClick,
7
+ label,
8
+ className,
9
+ }) => {
10
+ return (
11
+ <div className={classNames(className, {"flex items-center": true})}>
12
+ <button
13
+ onClick={onClick}
14
+ type="button"
15
+ role="switch"
16
+ aria-checked="false"
17
+ className={classNames({
18
+ "bg-green-500": value,
19
+ "bg-gray-200": !value,
20
+ },
21
+ "relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition duration-100 ease-in-out focus:outline-none")}
22
+ >
23
+ <span
24
+ aria-hidden="true"
25
+ className={classNames({
26
+ "translate-x-5": value,
27
+ "translate-x-0": !value,
28
+ },
29
+ "pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow ring-0 transition duration-100 ease-in-out")}
30
+ />
31
+ </button>
32
+ <span className="ml-2">{label}</span>
33
+ </div>
34
+ );
35
+ };
@@ -9,6 +9,7 @@ import {ElementAutocomplete} from "./ElementAutocomplete";
9
9
  import {
10
10
  CollapsableMenu, CollapsableMenuItem,
11
11
  } from "./CollapsableMenu/CollapsableMenu";
12
+ import {Switch} from "./SidebarEditor/Switch";
12
13
 
13
14
  const SidebarEditor = ({
14
15
  sdk,
@@ -317,6 +318,12 @@ const SidebarEditor = ({
317
318
  <CollapsableMenuItem onClick={onDuplicate}>Duplizieren</CollapsableMenuItem>
318
319
  <CollapsableMenuItem onClick={() => onInsert("above")}>Davor hinzufügen</CollapsableMenuItem>
319
320
  <CollapsableMenuItem onClick={() => onInsert("below")}>Danach hinzufügen</CollapsableMenuItem>
321
+ <div className="px-4 pb-2 pt-1">
322
+ <b className="mb-1 block text-sm">Responsive:</b>
323
+ <Switch value={!storybookElement.attributes.hideOnDesktop} label="Desktop" className="mb-2" onClick={() => handleFieldValueChange("hideOnDesktop", !storybookElement.attributes.hideOnDesktop)} />
324
+ <Switch value={!storybookElement.attributes.hideOnTablet} label="Tablet" className="mb-2" onClick={() => handleFieldValueChange("hideOnTablet", !storybookElement.attributes.hideOnTablet)} />
325
+ <Switch value={!storybookElement.attributes.hideOnSmartphone} label="Smartphone" className="mb-2" onClick={() => handleFieldValueChange("hideOnSmartphone", !storybookElement.attributes.hideOnSmartphone)} />
326
+ </div>
320
327
  </CollapsableMenu>
321
328
  </div>
322
329
  )}