@bigbinary/neeto-themes-frontend 2.0.8 → 2.0.10
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/README.md +88 -18
- package/dist/index.cjs.js +17 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +17 -6
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/types.d.ts +2 -1
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# neeto-themes-nano
|
|
2
2
|
|
|
3
|
-
The `neeto-themes-nano`
|
|
4
|
-
configs, data etc.
|
|
3
|
+
The `neeto-themes-nano` allows us to build and use themes within neeto applications. This nano exports `@bigbinary/neeto-themes-frontend` NPM package and `neeto-themes-engine` Rails engine.
|
|
5
4
|
|
|
6
5
|
## Contents
|
|
7
6
|
|
|
@@ -51,25 +50,71 @@ configs, data etc.
|
|
|
51
50
|
bundle exec rails db:migrate
|
|
52
51
|
```
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
5. Add the following line to `models/organization.rb` file.
|
|
55
54
|
|
|
56
|
-
|
|
55
|
+
```ruby
|
|
56
|
+
has_many :themes, class_name: "NeetoThemesEngine::Theme", as: :owner
|
|
57
|
+
```
|
|
58
|
+
6. Configure model to add below association to attach theme.
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
```ruby
|
|
61
|
+
has_one :theme_entity, as: :themeable, class_name: "NeetoThemesEngine::ThemeEntity", dependent: :destroy
|
|
62
|
+
has_one :theme, through: :theme_entity, class_name: "NeetoThemesEngine::Theme"
|
|
63
|
+
```
|
|
60
64
|
|
|
61
|
-
|
|
65
|
+
### Usage
|
|
62
66
|
|
|
63
|
-
|
|
67
|
+
1. **Create an engine initializer**
|
|
64
68
|
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
Create a file named `neeto_themes_engine.rb` in the `config/initializers` folder.
|
|
70
|
+
|
|
71
|
+
2. **Customize theme schema**
|
|
72
|
+
|
|
73
|
+
The engine supports customizing theme schemas based on the needs of the host application. This schema will be used in the frontend to render the theme properties. Eg:
|
|
74
|
+
|
|
75
|
+
```ruby
|
|
76
|
+
NeetoThemesEngine.theme_properties_schema = [
|
|
77
|
+
{ kind: "color", key: "primary_color", default_value: "#2D36D4" },
|
|
78
|
+
{ kind: "color", key: "secondary_color", default_value: "#ECF4FF" },
|
|
79
|
+
]
|
|
67
80
|
```
|
|
68
81
|
|
|
69
|
-
|
|
82
|
+
Each object in the array should have the following keys:
|
|
83
|
+
- `key`: The unique identifier for the theme property.
|
|
84
|
+
|
|
85
|
+
- `kind`: The kind of the theme property.
|
|
86
|
+
|
|
87
|
+
Optional keys that can be included:
|
|
88
|
+
|
|
89
|
+
- `default_value`: Sets a default value when creating a new theme.
|
|
90
|
+
|
|
91
|
+
- `hidden`: This boolean prop helps to hide the property from the UI but allows to use it as CSS variable.
|
|
92
|
+
|
|
93
|
+
- `depends_on`: Provides a dependency on other properties. If a key is provided, it will check for its value and only appear in the UI if the dependent property is present.
|
|
94
|
+
|
|
95
|
+
3. **Provide a css variable prefix**
|
|
96
|
+
|
|
97
|
+
This value will be used to prefix all CSS variables. Eg:
|
|
98
|
+
|
|
99
|
+
```ruby
|
|
100
|
+
NeetoThemesEngine.css_variable_prefix = "neeto-cal"
|
|
101
|
+
```
|
|
102
|
+
variable generated for the theme property `primary_color` will be `--neeto-cal-primary-color`.
|
|
103
|
+
|
|
104
|
+
4. **Provide the entities to which the theme property is attached**
|
|
70
105
|
|
|
71
|
-
|
|
72
|
-
|
|
106
|
+
This value will be used to determine the entity to which the theme property is attached. We can provide multiple entities. Eg:
|
|
107
|
+
|
|
108
|
+
```ruby
|
|
109
|
+
NeetoThemesEngine.valid_themeable_types = ["Meeting", "Booking"]
|
|
110
|
+
```
|
|
111
|
+
5. **Provide a default theme name** (Optional)
|
|
112
|
+
|
|
113
|
+
This provided value will be used to identify the default theme. If not provided, the default theme will be named "Plain blue".
|
|
114
|
+
|
|
115
|
+
```ruby
|
|
116
|
+
NeetoThemesEngine.default_theme_name = "My theme"
|
|
117
|
+
```
|
|
73
118
|
|
|
74
119
|
### Frontend package
|
|
75
120
|
|
|
@@ -84,20 +129,45 @@ Notes ⚠️
|
|
|
84
129
|
### Instructions for development
|
|
85
130
|
Check the [Frontend package development guide](https://neeto-engineering.neetokb.com/p/a-d34cb4b0) for step-by-step instructions to develop the frontend package.
|
|
86
131
|
|
|
87
|
-
|
|
132
|
+
### Usage
|
|
133
|
+
|
|
134
|
+
#### Components
|
|
88
135
|
|
|
89
|
-
1. Import `
|
|
136
|
+
1. Import the `NeetoThemesBuilder` component from `@bigbinary/neeto-themes-frontend`:
|
|
90
137
|
|
|
91
138
|
```javascript
|
|
92
139
|
import React from "react";
|
|
140
|
+
import { NeetoThemesBuilder } from "@bigbinary/neeto-themes-frontend";
|
|
141
|
+
|
|
142
|
+
const App = () => (
|
|
143
|
+
<NeetoThemesBuilder
|
|
144
|
+
entityId={meeting?.id}
|
|
145
|
+
entityType="Meeting"
|
|
146
|
+
thumbnail={Thumbnail}
|
|
147
|
+
>
|
|
148
|
+
<Preview />
|
|
149
|
+
</NeetoThemesBuilder>
|
|
150
|
+
);
|
|
93
151
|
|
|
94
|
-
|
|
152
|
+
export default App;
|
|
95
153
|
|
|
96
|
-
|
|
154
|
+
#### hooks
|
|
97
155
|
|
|
98
|
-
|
|
156
|
+
1. Import `useThemeUtils` hook from "@bigbinary/neeto-themes-frontend"
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
import { useThemeUtils } from "@bigbinary/neeto-themes-frontend";
|
|
160
|
+
|
|
161
|
+
const { setTheme,previewingTheme, currentTheme } = useThemeUtils();
|
|
99
162
|
```
|
|
100
163
|
|
|
164
|
+
- `setTheme`: This method is used to set the theme for the entity.
|
|
165
|
+
|
|
166
|
+
- `previewingTheme`: This object contains the currently previewing theme.
|
|
167
|
+
|
|
168
|
+
- `currentTheme`: This object contains the current theme which is applied to the entity.
|
|
169
|
+
|
|
170
|
+
|
|
101
171
|
## Instructions for Publishing
|
|
102
172
|
|
|
103
173
|
Consult the
|
package/dist/index.cjs.js
CHANGED
|
@@ -982,7 +982,9 @@ var Properties = function Properties(_ref) {
|
|
|
982
982
|
var index = neetoCist.findIndexBy({
|
|
983
983
|
key: name
|
|
984
984
|
}, values.properties);
|
|
985
|
-
if (index !== -1
|
|
985
|
+
if (index !== -1 && values.properties[index].value !== value) {
|
|
986
|
+
setFieldValue("properties[".concat(index, "].value"), value);
|
|
987
|
+
}
|
|
986
988
|
setVariable(neetoCist.snakeToCamelCase(name), variableValue !== null && variableValue !== void 0 ? variableValue : value);
|
|
987
989
|
};
|
|
988
990
|
var handleOverlayChange = function handleOverlayChange(key, value) {
|
|
@@ -1148,7 +1150,8 @@ var Customize = function Customize(_ref) {
|
|
|
1148
1150
|
onCreateTheme = _ref.onCreateTheme,
|
|
1149
1151
|
onApplyTheme = _ref.onApplyTheme,
|
|
1150
1152
|
isApplyingTheme = _ref.isApplyingTheme,
|
|
1151
|
-
onPropertiesChange = _ref.onPropertiesChange
|
|
1153
|
+
onPropertiesChange = _ref.onPropertiesChange,
|
|
1154
|
+
onUpdateThemeSuccess = _ref.onUpdateThemeSuccess;
|
|
1152
1155
|
var _useTranslation = reactI18next.useTranslation(),
|
|
1153
1156
|
t = _useTranslation.t;
|
|
1154
1157
|
var _useState = react.useState({}),
|
|
@@ -1194,9 +1197,10 @@ var Customize = function Customize(_ref) {
|
|
|
1194
1197
|
}
|
|
1195
1198
|
return updateTheme(themeToSave, {
|
|
1196
1199
|
onSuccess: function onSuccess() {
|
|
1197
|
-
|
|
1200
|
+
resetForm({
|
|
1198
1201
|
values: values
|
|
1199
1202
|
});
|
|
1203
|
+
onUpdateThemeSuccess === null || onUpdateThemeSuccess === void 0 || onUpdateThemeSuccess(values);
|
|
1200
1204
|
}
|
|
1201
1205
|
});
|
|
1202
1206
|
};
|
|
@@ -1532,11 +1536,13 @@ var Card = function Card(_ref) {
|
|
|
1532
1536
|
},
|
|
1533
1537
|
menuItems: [{
|
|
1534
1538
|
key: "edit",
|
|
1539
|
+
"data-cy": "edit-theme-menu-item",
|
|
1535
1540
|
label: t("neetoThemes.common.edit"),
|
|
1536
1541
|
isVisible: neetoCist.isPresent(onEditTheme),
|
|
1537
1542
|
onClick: handleEditTheme
|
|
1538
1543
|
}, {
|
|
1539
1544
|
key: "clone",
|
|
1545
|
+
"data-cy": "clone-theme-menu-item",
|
|
1540
1546
|
label: t("neetoThemes.build.leftSideBar.themes.themeOptions.clone"),
|
|
1541
1547
|
onClick: handleCloneTheme
|
|
1542
1548
|
}, {
|
|
@@ -1767,7 +1773,8 @@ var Sidebar = function Sidebar(_ref) {
|
|
|
1767
1773
|
var _themeToEdit$current, _themeToEdit$current2, _themeToDelete$curren2, _themeToDelete$curren3, _themeToDelete$curren4;
|
|
1768
1774
|
var thumbnail = _ref.thumbnail,
|
|
1769
1775
|
onPropertiesChange = _ref.onPropertiesChange,
|
|
1770
|
-
onApplyThemeSuccess = _ref.onApplyThemeSuccess
|
|
1776
|
+
onApplyThemeSuccess = _ref.onApplyThemeSuccess,
|
|
1777
|
+
onUpdateThemeSuccess = _ref.onUpdateThemeSuccess;
|
|
1771
1778
|
var _useState = react.useState(DESIGN_SCREENS.THEMES),
|
|
1772
1779
|
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
1773
1780
|
currentScreen = _useState2[0],
|
|
@@ -1834,7 +1841,7 @@ var Sidebar = function Sidebar(_ref) {
|
|
|
1834
1841
|
});
|
|
1835
1842
|
setThemeBeingApplied({});
|
|
1836
1843
|
setCurrentScreen(DESIGN_SCREENS.THEMES);
|
|
1837
|
-
onApplyThemeSuccess === null || onApplyThemeSuccess === void 0 || onApplyThemeSuccess();
|
|
1844
|
+
onApplyThemeSuccess === null || onApplyThemeSuccess === void 0 || onApplyThemeSuccess(theme);
|
|
1838
1845
|
}
|
|
1839
1846
|
}),
|
|
1840
1847
|
applyTheme = _useApplyTheme.mutate,
|
|
@@ -1930,6 +1937,7 @@ var Sidebar = function Sidebar(_ref) {
|
|
|
1930
1937
|
onApplyTheme: onApplyTheme,
|
|
1931
1938
|
onCreateTheme: onCreateTheme,
|
|
1932
1939
|
onPropertiesChange: onPropertiesChange,
|
|
1940
|
+
onUpdateThemeSuccess: onUpdateThemeSuccess,
|
|
1933
1941
|
theme: themeToEdit.current,
|
|
1934
1942
|
themeId: (_themeToEdit$current2 = themeToEdit.current) === null || _themeToEdit$current2 === void 0 ? void 0 : _themeToEdit$current2.id
|
|
1935
1943
|
}), /*#__PURE__*/jsxRuntime.jsx(MemoizedAlert, {
|
|
@@ -1959,7 +1967,9 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
|
|
|
1959
1967
|
_ref$isTemplateThemes = _ref.isTemplateThemesEnabled,
|
|
1960
1968
|
isTemplateThemesEnabled = _ref$isTemplateThemes === void 0 ? false : _ref$isTemplateThemes,
|
|
1961
1969
|
_ref$onApplyThemeSucc = _ref.onApplyThemeSuccess,
|
|
1962
|
-
onApplyThemeSuccess = _ref$onApplyThemeSucc === void 0 ? neetoCist.noop : _ref$onApplyThemeSucc
|
|
1970
|
+
onApplyThemeSuccess = _ref$onApplyThemeSucc === void 0 ? neetoCist.noop : _ref$onApplyThemeSucc,
|
|
1971
|
+
_ref$onUpdateThemeSuc = _ref.onUpdateThemeSuccess,
|
|
1972
|
+
onUpdateThemeSuccess = _ref$onUpdateThemeSuc === void 0 ? neetoCist.noop : _ref$onUpdateThemeSuc;
|
|
1963
1973
|
var _useThemeStore = useThemeStore(function (store) {
|
|
1964
1974
|
return {
|
|
1965
1975
|
setThemeState: store["setThemeState"]
|
|
@@ -2008,6 +2018,7 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
|
|
|
2008
2018
|
children: [/*#__PURE__*/jsxRuntime.jsx(Sidebar, {
|
|
2009
2019
|
onApplyThemeSuccess: onApplyThemeSuccess,
|
|
2010
2020
|
onPropertiesChange: onPropertiesChange,
|
|
2021
|
+
onUpdateThemeSuccess: onUpdateThemeSuccess,
|
|
2011
2022
|
thumbnail: thumbnail
|
|
2012
2023
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2013
2024
|
className: "neeto-themes-preview__wrapper",
|