Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions app/client/packages/design-system/theming/src/utils/cssRule.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
import kebabCase from "lodash/kebabCase";
import isObject from "lodash/isObject";
import type { Theme } from "../theme";
import { objectKeys } from "@appsmith/utils";
import type { TypographyVariantMetric } from "../token";

export const cssRule = (tokens: Theme) => {
let styles = "";

Object.values(tokens).forEach((token) => {
objectKeys(tokens).forEach((tokenKey) => {
const token = tokens[tokenKey];

if (token == null) return;

if (isObject(token)) {
Object.keys(token).forEach((key) => {
if (tokenKey === "typography") {
styles += objectKeys(token as NonNullable<Theme["typography"]>).reduce(
(prev: string, key) => {
return `${prev} --font-size-${key}: ${(token[key] as TypographyVariantMetric).fontSize};`;
},
"",
);

return;
}
Comment thread
KelvinOm marked this conversation as resolved.

objectKeys(token).forEach((key) => {
//@ts-expect-error: type mismatch
styles += `--${kebabCase(token[key].type)}-${kebabCase(key)}: ${
//@ts-expect-error: type mismatch
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
(function (nativeConsole) {
const postMessage = (method, args) => {
window.parent.postMessage(
{
type: "CUSTOM_WIDGET_CONSOLE_EVENT",
data: {
type: method,
args: args.map((d) => ({
message: d,
})),
},
},
"*",
Comment thread
KelvinOm marked this conversation as resolved.
);
};

const createProxy = (method) =>
new Proxy(nativeConsole[method], {
apply(target, _this, args) {
try {
postMessage(method, args);
} finally {
return Reflect.apply(target, _this, args);
}
Comment thread
KelvinOm marked this conversation as resolved.
},
});

["log", "warn", "info"].forEach((method) => {
nativeConsole[method] = createProxy(method);
});

window.addEventListener("error", (event) => {
postMessage("error", [event.message]);
});
})(window.console);
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const CUSTOM_WIDGET_LOAD_EVENTS = {
STARTED: "started",
DOM_CONTENTED_LOADED: "DOMContentLoaded",
COMPLETED: "completed",
};

export const getAppsmithScriptSchema = (model: Record<string, unknown>) => ({
appsmith: {
mode: "",
model: model,
onUiChange: Function,
onModelChange: Function,
onThemeChange: Function,
updateModel: Function,
triggerEvent: Function,
onReady: Function,
Comment thread
KelvinOm marked this conversation as resolved.
},
});
Loading