Skip to content

Commit

Permalink
Adjust prettier config to match internal style guide
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwillchen committed Dec 7, 2023
1 parent 43cf615 commit 0377fa8
Show file tree
Hide file tree
Showing 36 changed files with 344 additions and 348 deletions.
22 changes: 11 additions & 11 deletions docs/stylesheets/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
--crater: #f0dfdf;
}

[data-md-color-scheme="optic-light"] {
[data-md-color-scheme='optic-light'] {
--md-default-bg-color--dark: var(--black);
--md-primary-fg-color: var(--galaxy);
--md-typeset-a-color: var(--flare);
--md-accent-fg-color: var(--cosmic);
}

[data-md-color-scheme="optic-dark"] {
[data-md-color-scheme='optic-dark'] {
--md-default-bg-color: var(--galaxy);
--md-default-fg-color: var(--white);
--md-default-fg-color--light: var(--white);
Expand Down Expand Up @@ -68,23 +68,23 @@
--md-typeset-table-color--light: hsla(0, 0%, 100%, 0.035);
}

[data-md-color-scheme="optic-light"] img[src$="#only-dark"],
[data-md-color-scheme="optic-light"] img[src$="#gh-dark-mode-only"] {
[data-md-color-scheme='optic-light'] img[src$='#only-dark'],
[data-md-color-scheme='optic-light'] img[src$='#gh-dark-mode-only'] {
display: none; /* Hide dark images in light mode */
}

[data-md-color-scheme="optic-light"] img[src$="#only-light"],
[data-md-color-scheme="optic-light"] img[src$="#gh-light-mode-only"] {
[data-md-color-scheme='optic-light'] img[src$='#only-light'],
[data-md-color-scheme='optic-light'] img[src$='#gh-light-mode-only'] {
display: inline; /* Show light images in light mode */
}

[data-md-color-scheme="optic-dark"] img[src$="#only-light"],
[data-md-color-scheme="optic-dark"] img[src$="#gh-light-mode-only"] {
[data-md-color-scheme='optic-dark'] img[src$='#only-light'],
[data-md-color-scheme='optic-dark'] img[src$='#gh-light-mode-only'] {
display: none; /* Hide light images in dark mode */
}

[data-md-color-scheme="optic-dark"] img[src$="#only-dark"],
[data-md-color-scheme="optic-dark"] img[src$="#gh-dark-mode-only"] {
[data-md-color-scheme='optic-dark'] img[src$='#only-dark'],
[data-md-color-scheme='optic-dark'] img[src$='#gh-dark-mode-only'] {
display: inline; /* Show dark images in dark mode */
}

Expand All @@ -97,7 +97,7 @@
}

/* See: https://github.com/optic-sh/ruff/issues/8519 */
[data-md-color-scheme="optic-dark"] details summary a {
[data-md-color-scheme='optic-dark'] details summary a {
color: var(--flare);
}

Expand Down
4 changes: 2 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ theme:

palette:
# Palette toggle for light mode
- media: "(prefers-color-scheme: light)"
- media: '(prefers-color-scheme: light)'
scheme: optic-light
toggle:
icon: material/brightness-7
name: Switch to light mode

# Palette toggle for dark mode
- media: "(prefers-color-scheme: dark)"
- media: '(prefers-color-scheme: dark)'
scheme: optic-dark
toggle:
icon: material/brightness-4
Expand Down
16 changes: 8 additions & 8 deletions optic/components/box/box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ import {
Component,
HostBinding,
Input,
} from "@angular/core";
} from '@angular/core';
import {
Key,
Type,
UserEvent,
} from "optic/optic/protos/ui_jspb_proto_pb/optic/protos/ui_pb";
import { BoxType } from "optic/optic/components/box/box_jspb_proto_pb/optic/components/box/box_pb";
import { Channel } from "../../../web/src/services/channel";
} from 'optic/optic/protos/ui_jspb_proto_pb/optic/protos/ui_pb';
import {BoxType} from 'optic/optic/components/box/box_jspb_proto_pb/optic/components/box/box_pb';
import {Channel} from '../../../web/src/services/channel';

@Component({
selector: "optic-box",
templateUrl: "box.ng.html",
selector: 'optic-box',
templateUrl: 'box.ng.html',
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
})
export class BoxComponent {
@Input({ required: true }) type!: Type;
@Input({required: true}) type!: Type;
@Input() key!: Key;
private _config!: BoxType;
isChecked = false;
Expand All @@ -36,7 +36,7 @@ export class BoxComponent {
return this._config;
}

@HostBinding("style") get style(): string {
@HostBinding('style') get style(): string {
return `
display: block;
background-color: ${this.config().getBackgroundColor()};`;
Expand Down
10 changes: 5 additions & 5 deletions optic/components/box/e2e/box_test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from "@playwright/test";
import {test, expect} from '@playwright/test';

test("test", async ({ page }) => {
await page.goto("/components/box/e2e/box_app");
expect(await page.getByText("hi1").textContent()).toContain("hi1");
expect(await page.getByText("hi2").textContent()).toContain("hi2");
test('test', async ({page}) => {
await page.goto('/components/box/e2e/box_app');
expect(await page.getByText('hi1').textContent()).toContain('hi1');
expect(await page.getByText('hi2').textContent()).toContain('hi2');
});
16 changes: 8 additions & 8 deletions optic/components/button/button.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { ChangeDetectionStrategy, Component, Input } from "@angular/core";
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
import {
Key,
Type,
UserEvent,
} from "optic/optic/protos/ui_jspb_proto_pb/optic/protos/ui_pb";
import { ButtonType } from "optic/optic/components/button/button_jspb_proto_pb/optic/components/button/button_pb";
import { Channel } from "../../../web/src/services/channel";
import { MatButtonModule } from "@angular/material/button";
} from 'optic/optic/protos/ui_jspb_proto_pb/optic/protos/ui_pb';
import {ButtonType} from 'optic/optic/components/button/button_jspb_proto_pb/optic/components/button/button_pb';
import {Channel} from '../../../web/src/services/channel';
import {MatButtonModule} from '@angular/material/button';

@Component({
selector: "optic-button",
templateUrl: "button.ng.html",
selector: 'optic-button',
templateUrl: 'button.ng.html',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [MatButtonModule],
})
export class ButtonComponent {
@Input({ required: true }) type!: Type;
@Input({required: true}) type!: Type;
@Input() key!: Key;
private _config!: ButtonType;
isChecked = false;
Expand Down
16 changes: 8 additions & 8 deletions optic/components/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { ChangeDetectionStrategy, Component, Input } from "@angular/core";
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
import {
Key,
Type,
UserEvent,
} from "optic/optic/protos/ui_jspb_proto_pb/optic/protos/ui_pb";
import { CheckboxType } from "optic/optic/components/checkbox/checkbox_jspb_proto_pb/optic/components/checkbox/checkbox_pb";
import { Channel } from "../../../web/src/services/channel";
} from 'optic/optic/protos/ui_jspb_proto_pb/optic/protos/ui_pb';
import {CheckboxType} from 'optic/optic/components/checkbox/checkbox_jspb_proto_pb/optic/components/checkbox/checkbox_pb';
import {Channel} from '../../../web/src/services/channel';

@Component({
selector: "optic-checkbox",
templateUrl: "checkbox.ng.html",
selector: 'optic-checkbox',
templateUrl: 'checkbox.ng.html',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CheckboxComponent {
@Input({ required: true }) type!: Type;
@Input({required: true}) type!: Type;
@Input() key!: Key;
private _config!: CheckboxType;
isChecked = false;
Expand All @@ -32,7 +32,7 @@ export class CheckboxComponent {
}

handleCheckboxChange(event: any) {
console.log("Checkbox is now:", event.target.checked);
console.log('Checkbox is now:', event.target.checked);
this.isChecked = event.target.checked;
const userEvent = new UserEvent();
userEvent.setBool(event.target.checked);
Expand Down
10 changes: 5 additions & 5 deletions optic/components/text/e2e/text_test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test, expect } from "@playwright/test";
import {test, expect} from '@playwright/test';

test("test", async ({ page }) => {
await page.goto("/components/text/e2e/text_app");
expect(await page.getByText("Hello, world!").textContent()).toContain(
"Hello, world!",
test('test', async ({page}) => {
await page.goto('/components/text/e2e/text_app');
expect(await page.getByText('Hello, world!').textContent()).toContain(
'Hello, world!',
);
});
12 changes: 6 additions & 6 deletions optic/components/text/text.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { ChangeDetectionStrategy, Component, Input } from "@angular/core";
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
import {
Key,
Type,
} from "optic/optic/protos/ui_jspb_proto_pb/optic/protos/ui_pb";
import { TextType } from "optic/optic/components/text/text_jspb_proto_pb/optic/components/text/text_pb";
} from 'optic/optic/protos/ui_jspb_proto_pb/optic/protos/ui_pb';
import {TextType} from 'optic/optic/components/text/text_jspb_proto_pb/optic/components/text/text_pb';

@Component({
selector: "optic-text",
templateUrl: "text.ng.html",
selector: 'optic-text',
templateUrl: 'text.ng.html',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TextComponent {
@Input({ required: true }) type!: Type;
@Input({required: true}) type!: Type;
@Input() key!: Key;
_config!: TextType;

Expand Down
16 changes: 8 additions & 8 deletions optic/components/text_input/e2e/text_input_test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { test, expect } from "@playwright/test";
import {test, expect} from '@playwright/test';

test("test", async ({ page }) => {
await page.goto("/components/text_input/e2e/text_input_app");
const textOutput = await page.getByText("Text output:");
expect(textOutput).toHaveText("Text output:initial_text_state");
test('test', async ({page}) => {
await page.goto('/components/text_input/e2e/text_input_app');
const textOutput = await page.getByText('Text output:');
expect(textOutput).toHaveText('Text output:initial_text_state');

// await page.getByLabel("simple-text-input").click();
await page.getByLabel("simple-text-input").fill("abcdef");
await page.locator("html").click();
await page.getByLabel('simple-text-input').fill('abcdef');
await page.locator('html').click();
// const textInput = await page.getByText("simple-text-input");
// await textInput.fill("entered_text");
// await textInput.blur();

// const progressBar = await page.getByTestId("connection-progress-bar");
// await progressBar.waitFor({ state: "hidden" });
// await new Promise((s) => setTimeout(s, 1000));
expect(textOutput).toHaveText("Text output:abcdef");
expect(textOutput).toHaveText('Text output:abcdef');
});
22 changes: 11 additions & 11 deletions optic/components/text_input/text_input.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { ChangeDetectionStrategy, Component, Input } from "@angular/core";
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
import {
Key,
Type,
UserEvent,
} from "optic/optic/protos/ui_jspb_proto_pb/optic/protos/ui_pb";
import { TextInputType } from "optic/optic/components/text_input/text_input_jspb_proto_pb/optic/components/text_input/text_input_pb";
import { Channel } from "../../../web/src/services/channel";
import { MatFormFieldModule } from "@angular/material/form-field";
import { MatInputModule } from "@angular/material/input";
import { FormsModule } from "@angular/forms";
import { ObserversModule } from "@angular/cdk/observers";
} from 'optic/optic/protos/ui_jspb_proto_pb/optic/protos/ui_pb';
import {TextInputType} from 'optic/optic/components/text_input/text_input_jspb_proto_pb/optic/components/text_input/text_input_pb';
import {Channel} from '../../../web/src/services/channel';
import {MatFormFieldModule} from '@angular/material/form-field';
import {MatInputModule} from '@angular/material/input';
import {FormsModule} from '@angular/forms';
import {ObserversModule} from '@angular/cdk/observers';

@Component({
selector: "optic-text-input",
templateUrl: "text_input.ng.html",
selector: 'optic-text-input',
templateUrl: 'text_input.ng.html',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [MatFormFieldModule, MatInputModule, FormsModule, ObserversModule],
})
export class TextInputComponent {
@Input({ required: true }) type!: Type;
@Input({required: true}) type!: Type;
@Input() key!: Key;
private _config!: TextInputType;
isChecked = false;
Expand Down
12 changes: 6 additions & 6 deletions optic/examples/e2e/simple_test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { test, expect } from "@playwright/test";
import {test, expect} from '@playwright/test';

test("test", async ({ page }) => {
await page.goto("/");
expect(await page.getByText("0 clicks").textContent()).toContain("0 clicks");
test('test', async ({page}) => {
await page.goto('/');
expect(await page.getByText('0 clicks').textContent()).toContain('0 clicks');

await page.getByRole("button", { name: "click me" }).click();
await page.getByRole('button', {name: 'click me'}).click();

expect(await page.getByText("1 clicks").textContent()).toContain("1 clicks");
expect(await page.getByText('1 clicks').textContent()).toContain('1 clicks');
});
26 changes: 13 additions & 13 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig, devices } from "@playwright/test";
import {defineConfig, devices} from '@playwright/test';

/**
* Read environment variables from file.
Expand All @@ -11,9 +11,9 @@ import { defineConfig, devices } from "@playwright/test";
*/
export default defineConfig({
timeout: 5000,
testDir: ".",
testMatch: "e2e/*_test.ts",
testIgnore: "scripts/**",
testDir: '.',
testMatch: 'e2e/*_test.ts',
testIgnore: 'scripts/**',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
Expand All @@ -22,33 +22,33 @@ export default defineConfig({
/* Force non-parallelism due to flakiness. */
workers: 1,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: "html",
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: "http://127.0.0.1:8080/",
baseURL: 'http://127.0.0.1:8080/',

/* See https://playwright.dev/docs/trace-viewer */
trace: "retain-on-failure",
trace: 'retain-on-failure',

// Capture screenshot after each test failure.
screenshot: "on",
screenshot: 'on',

video: "retain-on-failure",
video: 'retain-on-failure',
},

/* Configure projects for major browsers */
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
name: 'chromium',
use: {...devices['Desktop Chrome']},
},
],

/* Run your local dev server before starting the tests */
webServer: {
command: "bazel run //optic/cli -- --path=optic/testing/index.py --debug",
url: "http://127.0.0.1:8080/",
command: 'bazel run //optic/cli -- --path=optic/testing/index.py --debug',
url: 'http://127.0.0.1:8080/',
reuseExistingServer: !process.env.CI,
},
});
4 changes: 3 additions & 1 deletion prettier.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** @type {import("prettier").Config} */
export default {
trailingComma: "all",
singleQuote: true,
quoteProps: 'preserve',
bracketSpacing: false,
};
Loading

0 comments on commit 0377fa8

Please sign in to comment.