Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WP Ai Global Styles #1994

Merged
merged 1 commit into from May 17, 2024
Merged

WP Ai Global Styles #1994

merged 1 commit into from May 17, 2024

Conversation

GunkaArtur
Copy link
Contributor

@GunkaArtur GunkaArtur commented Apr 4, 2024

@GunkaArtur GunkaArtur self-assigned this Apr 4, 2024
@GunkaArtur
Copy link
Contributor Author

URL from config will be added here https://github.com/bagrinsergiu/blox-editor/issues/26071


export const getAIGlobalStyles = (): AiGlobalStyles<Palette, FontStyle> => {
const apiUrl =
"https://phplaravel-1109775-4163586.cloudwaysapps.com/api/template";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use url from config

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return {
async getColors(res, rej) {
try {
const styles = await fetch(`${apiUrl}/style`).then((r) => r.json());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use async/await without then:

const styles = await getStyles(/* ... */)

},
async getTypography(res, rej) {
try {
const data = await fetch(`${apiUrl}/typography`).then((r) => r.json());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here also use async/await without then

@@ -93,6 +93,7 @@ public function getClientConfig($context)
'project' => array(
'status' => $this->getProjectStatus(),
),
'aiGlobalStyleUrl' => 'https://phplaravel-1109775-4163586.cloudwaysapps.com'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to be revied

async getColors(res, rej) {
try {
const styles = await fetch(
`${aiGlobalStyleUrl}/api/template/style`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as editor api client

alecszaharia added a commit that referenced this pull request May 2, 2024
@GunkaArtur GunkaArtur force-pushed the 25691-wp-ai-global-styles branch 2 times, most recently from 3262ca7 to 7d60fd6 Compare May 2, 2024 08:03

res(styles.colorPalette);
} catch (e) {
rej(t("Failed to load meta.json"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review reject message


res(data.fontStyles);
} catch (e) {
rej(t("Failed to load resolves for selected DefaultTemplate"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review reject message

shouldn't be something like: "failed to load typography..." ?

@@ -5,6 +5,15 @@ export interface DefaultBlock {
value: Record<string, unknown>;
}

export interface AiGlobalStyles<T1, T2> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename AiGlobalStyles

as i see in previous @maxval1 review there is nothing with AI

set(
window.__VISUAL_CONFIG__.ui,
["leftSidebar", "styles"],
getAIGlobalStyles(config)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename also this function

@lift46252 lift46252 added review and removed review labels May 14, 2024
@alecszaharia alecszaharia merged commit 46dd323 into develop May 17, 2024
@maxval1 maxval1 deleted the 25691-wp-ai-global-styles branch May 17, 2024 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants