Skip to content

Commit

Permalink
squash
Browse files Browse the repository at this point in the history
  • Loading branch information
Drew-Daniels committed Aug 4, 2024
1 parent e777273 commit ed386dd
Show file tree
Hide file tree
Showing 134 changed files with 2,649 additions and 1,027 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

42 changes: 0 additions & 42 deletions .eslintrc.json

This file was deleted.

2 changes: 2 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tools]
node = "22.5.1"
Binary file modified .yarn/install-state.gz
Binary file not shown.
29 changes: 29 additions & 0 deletions apps/iframe-react-app-e2e/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const { FlatCompat } = require('@eslint/eslintrc');
const baseConfig = require('../../eslint.config.js');
const js = require('@eslint/js');

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
});

module.exports = [
...baseConfig,
...compat.extends('plugin:playwright/recommended'),
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
rules: {},
},
{
files: ['**/*.ts', '**/*.tsx'],
rules: {},
},
{
files: ['**/*.js', '**/*.jsx'],
rules: {},
},
{
files: ['src/**/*.{ts,js,tsx,jsx}'],
rules: {},
},
];
69 changes: 69 additions & 0 deletions apps/iframe-react-app-e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { defineConfig, devices } from '@playwright/test';
import { nxE2EPreset } from '@nx/playwright/preset';

import { workspaceRoot } from '@nx/devkit';

// For CI, you may want to set BASE_URL to the deployed application.
const baseURL = process.env['BASE_URL'] || 'http://localhost:4200';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
...nxE2EPreset(__filename, { testDir: './src' }),
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
baseURL,
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
/* Run your local dev server before starting the tests */
webServer: {
command: 'yarn nx serve iframe-react-app',
url: 'http://localhost:4200',
reuseExistingServer: !process.env.CI,
cwd: workspaceRoot,
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

// Uncomment for mobile browsers support
/* {
name: 'Mobile Chrome',
use: { ...devices['Pixel 5'] },
},
{
name: 'Mobile Safari',
use: { ...devices['iPhone 12'] },
}, */

// Uncomment for branded browsers
/* {
name: 'Microsoft Edge',
use: { ...devices['Desktop Edge'], channel: 'msedge' },
},
{
name: 'Google Chrome',
use: { ...devices['Desktop Chrome'], channel: 'chrome' },
} */
],
});
9 changes: 9 additions & 0 deletions apps/iframe-react-app-e2e/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "iframe-react-app-e2e",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/iframe-react-app-e2e/src",
"implicitDependencies": ["iframe-react-app"],
"// targets": "to see all targets run: nx show project iframe-react-app-e2e --web",
"targets": {}
}
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions apps/iframe-react-app/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_PARENT_WINDOW_URL="http://localhost:4200"
25 changes: 25 additions & 0 deletions apps/iframe-react-app/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const { FlatCompat } = require('@eslint/eslintrc');
const baseConfig = require('../../eslint.config.js');
const js = require('@eslint/js');

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
});

module.exports = [
...baseConfig,
...compat.extends('plugin:@nx/react'),
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
rules: {},
},
{
files: ['**/*.ts', '**/*.tsx'],
rules: {},
},
{
files: ['**/*.js', '**/*.jsx'],
rules: {},
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Liaison</title>
<title>IframeReactApp</title>
<base href="/" />

<meta name="viewport" content="width=device-width, initial-scale=1" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable */
export default {
displayName: 'liaison',
displayName: 'iframe-react-app',
preset: '../../jest.preset.js',
transform: {
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/apps/liaison',
coverageDirectory: '../../coverage/apps/iframe-react-app',
};
File renamed without changes.
9 changes: 9 additions & 0 deletions apps/iframe-react-app/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "iframe-react-app",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/iframe-react-app/src",
"projectType": "application",
"tags": [],
"// targets": "to see all targets run: nx show project iframe-react-app --web",
"targets": {}
}
File renamed without changes.
25 changes: 25 additions & 0 deletions apps/iframe-react-app/src/app/app.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { render } from '@testing-library/react';

import { BrowserRouter } from 'react-router-dom';

import App from './app';

describe('App', () => {
it('should render successfully', () => {
const { baseElement } = render(
<BrowserRouter>
<App />
</BrowserRouter>
);
expect(baseElement).toBeTruthy();
});

it('should have a greeting as the title', () => {
const { getByText } = render(
<BrowserRouter>
<App />
</BrowserRouter>
);
expect(getByText(/Welcome iframe-react-app/gi)).toBeTruthy();
});
});
48 changes: 48 additions & 0 deletions apps/iframe-react-app/src/app/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { useState } from 'react';

import { useIFrame } from '@liaison/react';
import { Button } from '@liaison/ui';

function App() {
const [email, setEmail] = useState('');

const { cb: callParentEffect } = useIFrame({
parentOrigin: import.meta.env.VITE_PARENT_WINDOW_URL,
// define the effects that the parent window can call on the iframe
effects: {
onParentWindowLogin: ({ args: { email } }) => {
if (email && typeof email === 'string') {
setEmail(email);
} else {
// callParentEffect({ name: 'onLoginFailed' });
}
},
onParentWindowLogout: () => {
setEmail('');
},
},
});

return (
<div className="flex flex-col items-center justify-center h-screen bg-gray-100">
{!email && <p>Logged out</p>}
{email && (
<div className="flex flex-col items-center justify-center gap-4">
<p>Logged in as: {email}</p>
<Button
onClick={() => {
setEmail('');
callParentEffect({
name: 'onIFrameLogout',
});
}}
>
Logout User (from iframe)
</Button>
</div>
)}
</div>
);
}

export default App;
File renamed without changes.
16 changes: 16 additions & 0 deletions apps/iframe-react-app/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { StrictMode } from 'react';
import * as ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';

import App from './app/app';

const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<StrictMode>
<BrowserRouter>
<App />
</BrowserRouter>
</StrictMode>
);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
35 changes: 35 additions & 0 deletions apps/iframe-react-app/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/// <reference types='vitest' />
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';

export default defineConfig({
root: __dirname,
cacheDir: '../../node_modules/.vite/apps/iframe-react-app',

server: {
port: 4200,
host: 'localhost',
},

preview: {
port: 4300,
host: 'localhost',
},

plugins: [react(), nxViteTsPaths()],

// Uncomment this if you are using workers.
// worker: {
// plugins: [ nxViteTsPaths() ],
// },

build: {
outDir: '../../dist/apps/iframe-react-app',
emptyOutDir: true,
reportCompressedSize: true,
commonjsOptions: {
transformMixedEsModules: true,
},
},
});
22 changes: 0 additions & 22 deletions apps/liaison-e2e/.eslintrc.json

This file was deleted.

9 changes: 0 additions & 9 deletions apps/liaison-e2e/project.json

This file was deleted.

18 changes: 0 additions & 18 deletions apps/liaison/.eslintrc.json

This file was deleted.

Loading

0 comments on commit ed386dd

Please sign in to comment.