├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── assets ├── aws-exports.png ├── basic-vite-cdk-cognito-auth.png ├── basic-vite.png ├── chat-ui-vite.png ├── empty-vite.png ├── full-stack-chat-ui-cognito-auth-01.png ├── full-stack-chat-ui-cognito-auth-02.png ├── full-stack-chat-ui-cognito-auth-03.png ├── full-stack-chat-ui-cognito-auth-04.png ├── fullstack-chat-ui-cognito-auth-architecture.png ├── fullstack-vite-cdk-cognito-auth-01.png ├── fullstack-vite-cdk-cognito-auth-02.png └── fullstack-vite-cdk-cognito-auth-architecture.png ├── basic-vite ├── .eslintrc.cjs ├── README.md ├── index.html ├── package-lock.json ├── package.json ├── postcss.config.js ├── prettier.config.cjs ├── public │ ├── favicon.ico │ ├── images │ │ ├── android-chrome-192x192.png │ │ ├── android-chrome-512x512.png │ │ ├── apple-touch-icon.png │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ ├── favicon.ico │ │ └── logo.png │ └── manifest.json ├── src │ ├── app.tsx │ ├── common │ │ ├── api-client │ │ │ ├── api-client.ts │ │ │ └── items-api-client.ts │ │ ├── constants.ts │ │ ├── helpers │ │ │ ├── storage-helper.ts │ │ │ └── text-helper.ts │ │ ├── hooks │ │ │ ├── use-navigation-panel-state.ts │ │ │ └── use-on-follow.ts │ │ ├── i18n │ │ │ └── property-filter-i18n-strings.ts │ │ ├── types.ts │ │ └── utils.ts │ ├── components │ │ ├── base-app-layout.tsx │ │ ├── global-header.tsx │ │ ├── navigation-panel.tsx │ │ └── wrappers │ │ │ ├── router-button-dropdown.tsx │ │ │ ├── router-button.tsx │ │ │ └── router-link.tsx │ ├── main.tsx │ ├── pages │ │ ├── dashboard │ │ │ ├── dashboard-header.tsx │ │ │ ├── dashboard-page.tsx │ │ │ ├── items-table.tsx │ │ │ └── statistics-block.tsx │ │ ├── not-found.tsx │ │ └── section1 │ │ │ ├── add-item │ │ │ └── add-item-page.tsx │ │ │ ├── all-items │ │ │ ├── all-items-header.tsx │ │ │ ├── all-items-page.tsx │ │ │ └── all-items-table.tsx │ │ │ └── view-item │ │ │ └── view-item-page.tsx │ ├── styles │ │ └── app.scss │ └── vite-env.d.ts ├── tsconfig.json ├── tsconfig.node.json └── vite.config.ts ├── chat-ui-vite ├── .eslintrc.cjs ├── README.md ├── index.html ├── package-lock.json ├── package.json ├── postcss.config.js ├── prettier.config.cjs ├── public │ ├── favicon.ico │ ├── images │ │ ├── android-chrome-192x192.png │ │ ├── android-chrome-512x512.png │ │ ├── apple-touch-icon.png │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ ├── favicon.ico │ │ └── logo.png │ └── manifest.json ├── src │ ├── app.tsx │ ├── common │ │ ├── constants.ts │ │ ├── helpers │ │ │ └── storage-helper.ts │ │ ├── hooks │ │ │ ├── use-navigation-panel-state.ts │ │ │ └── use-on-follow.ts │ │ └── types.ts │ ├── components │ │ ├── base-app-layout.tsx │ │ ├── chat-ui │ │ │ ├── chat-ui-input-panel.tsx │ │ │ ├── chat-ui-message-list.tsx │ │ │ ├── chat-ui-message.tsx │ │ │ ├── chat-ui.tsx │ │ │ └── types.tsx │ │ ├── global-header.tsx │ │ ├── navigation-panel.tsx │ │ └── wrappers │ │ │ ├── router-button-dropdown.tsx │ │ │ ├── router-button.tsx │ │ │ └── router-link.tsx │ ├── main.tsx │ ├── pages │ │ ├── chat-page.tsx │ │ └── not-found.tsx │ ├── styles │ │ ├── app.scss │ │ └── chat-ui.module.scss │ └── vite-env.d.ts ├── tsconfig.json ├── tsconfig.node.json └── vite.config.ts ├── empty-vite ├── .eslintrc.cjs ├── README.md ├── index.html ├── package-lock.json ├── package.json ├── postcss.config.js ├── prettier.config.cjs ├── public │ ├── favicon.ico │ ├── images │ │ ├── android-chrome-192x192.png │ │ ├── android-chrome-512x512.png │ │ ├── apple-touch-icon.png │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ ├── favicon.ico │ │ └── logo.png │ └── manifest.json ├── src │ ├── app.tsx │ ├── common │ │ ├── constants.ts │ │ ├── helpers │ │ │ └── storage-helper.ts │ │ ├── hooks │ │ │ ├── use-navigation-panel-state.ts │ │ │ └── use-on-follow.ts │ │ └── types.ts │ ├── components │ │ ├── base-app-layout.tsx │ │ ├── global-header.tsx │ │ ├── navigation-panel.tsx │ │ └── wrappers │ │ │ ├── router-button-dropdown.tsx │ │ │ ├── router-button.tsx │ │ │ └── router-link.tsx │ ├── main.tsx │ ├── pages │ │ ├── home.tsx │ │ └── not-found.tsx │ ├── styles │ │ └── app.scss │ └── vite-env.d.ts ├── tsconfig.json ├── tsconfig.node.json └── vite.config.ts ├── full-stack-chat-ui-cognito-auth ├── .eslintrc.cjs ├── .npmignore ├── README.md ├── bin │ └── index.ts ├── cdk.json ├── functions │ └── api-handler │ │ ├── index.py │ │ ├── requirements.txt │ │ ├── routes │ │ ├── chat.py │ │ └── health.py │ │ └── utils.py ├── jest.config.js ├── lib │ ├── infrastructure-stack.ts │ └── utils.ts ├── package-lock.json ├── package.json ├── prettier.config.cjs ├── tsconfig.json └── user-interface │ ├── .eslintrc.cjs │ ├── README.md │ ├── index.html │ ├── package-lock.json │ ├── package.json │ ├── postcss.config.js │ ├── prettier.config.cjs │ ├── public │ ├── aws-exports.template.json │ ├── favicon.ico │ ├── images │ │ ├── android-chrome-192x192.png │ │ ├── android-chrome-512x512.png │ │ ├── apple-touch-icon.png │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ ├── favicon.ico │ │ └── logo.png │ └── manifest.json │ ├── src │ ├── app.tsx │ ├── common │ │ ├── api-client │ │ │ ├── api-client-base.ts │ │ │ ├── api-client.ts │ │ │ └── chat-api-client.ts │ │ ├── constants.ts │ │ ├── helpers │ │ │ └── storage-helper.ts │ │ ├── hooks │ │ │ ├── use-navigation-panel-state.ts │ │ │ └── use-on-follow.ts │ │ └── types.ts │ ├── components │ │ ├── app-configured.tsx │ │ ├── base-app-layout.tsx │ │ ├── chat-ui │ │ │ ├── Avatar.tsx │ │ │ ├── BaseChatMessage.tsx │ │ │ ├── CopyButton.tsx │ │ │ ├── chat-ui-input-panel.tsx │ │ │ ├── chat-ui-message.tsx │ │ │ ├── chat-ui.tsx │ │ │ └── types.tsx │ │ ├── global-header.tsx │ │ ├── navigation-panel.tsx │ │ └── wrappers │ │ │ ├── router-button-dropdown.tsx │ │ │ ├── router-button.tsx │ │ │ └── router-link.tsx │ ├── main.tsx │ ├── pages │ │ ├── chat-page.tsx │ │ └── not-found.tsx │ ├── styles │ │ ├── app.scss │ │ └── chat-ui.module.scss │ └── vite-env.d.ts │ ├── tsconfig.json │ ├── tsconfig.node.json │ └── vite.config.ts └── fullstack-vite-cdk-cognito-auth ├── .eslintrc.cjs ├── .npmignore ├── README.md ├── bin └── index.ts ├── cdk.json ├── functions └── api-handler │ ├── index.py │ ├── requirements.txt │ ├── routes │ ├── health.py │ └── items.py │ └── utils.py ├── jest.config.js ├── lib ├── infrastructure-stack.ts └── utils.ts ├── package-lock.json ├── package.json ├── prettier.config.cjs ├── tsconfig.json └── user-interface ├── index.html ├── package.json ├── postcss.config.js ├── prettier.config.cjs ├── public ├── aws-exports.template.json ├── favicon.ico ├── images │ ├── android-chrome-192x192.png │ ├── android-chrome-512x512.png │ ├── apple-touch-icon.png │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── favicon.ico │ └── logo.png └── manifest.json ├── src ├── app.tsx ├── common │ ├── api-client │ │ ├── api-client-base.ts │ │ ├── api-client.ts │ │ └── items-api-client.ts │ ├── constants.ts │ ├── helpers │ │ ├── storage-helper.ts │ │ └── text-helper.ts │ ├── hooks │ │ ├── use-form.ts │ │ ├── use-navigation-panel-state.ts │ │ └── use-on-follow.ts │ ├── i18n │ │ └── property-filter-i18n-strings.ts │ ├── types.ts │ └── utils.ts ├── components │ ├── app-configured.tsx │ ├── base-app-layout.tsx │ ├── global-header.tsx │ ├── modals │ │ └── item-delete-modal.tsx │ ├── navigation-panel.tsx │ └── wrappers │ │ ├── router-button-dropdown.tsx │ │ ├── router-button.tsx │ │ └── router-link.tsx ├── main.tsx ├── pages │ ├── dashboard │ │ ├── dashboard-header.tsx │ │ ├── dashboard-page.tsx │ │ ├── items-table.tsx │ │ └── statistics-block.tsx │ ├── not-found.tsx │ └── section1 │ │ ├── add-item │ │ └── add-item-page.tsx │ │ ├── all-items │ │ ├── all-items-header.tsx │ │ ├── all-items-page.tsx │ │ └── all-items-table.tsx │ │ └── view-item │ │ └── view-item-page.tsx ├── styles │ └── app.scss └── vite-env.d.ts ├── tsconfig.json ├── tsconfig.node.json └── vite.config.ts /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | 10 | ## Reporting Bugs/Feature Requests 11 | 12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 13 | 14 | When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already 15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 16 | 17 | * A reproducible test case or series of steps 18 | * The version of our code being used 19 | * Any modifications you've made relevant to the bug 20 | * Anything unusual about your environment or deployment 21 | 22 | 23 | ## Contributing via Pull Requests 24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 25 | 26 | 1. You are working against the latest source on the *main* branch. 27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 29 | 30 | To send us a pull request, please: 31 | 32 | 1. Fork the repository. 33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 34 | 3. Ensure local tests pass. 35 | 4. Commit to your fork using clear commit messages. 36 | 5. Send us a pull request, answering any default questions in the pull request interface. 37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 38 | 39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 41 | 42 | 43 | ## Finding contributions to work on 44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start. 45 | 46 | 47 | ## Code of Conduct 48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 50 | opensource-codeofconduct@amazon.com with any additional questions or comments. 51 | 52 | 53 | ## Security issue notifications 54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 55 | 56 | 57 | ## Licensing 58 | 59 | See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT No Attribution 2 | 3 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 13 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 14 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 15 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 16 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cloudscape Examples 2 | 3 | [https://cloudscape.design/](https://cloudscape.design/) 4 | 5 | Cloudscape is an open source design system for the cloud. Cloudscape offers user interface guidelines, front-end components, design resources, and development tools for building intuitive, engaging, and inclusive user experiences at scale. 6 | 7 | This repository provides ready-to-use examples of Cloudscape React projects. 8 | 9 | ![sample](assets/basic-vite.png "Cloudscape") 10 | ![sample](assets/chat-ui-vite.png "ChatUI") 11 | ![sample](assets/full-stack-chat-ui-cognito-auth-04.png "ChatBotUI") 12 | 13 | 14 | # Examples 15 | 16 | |Name|Description| 17 | |:-------------|:-------------| 18 | |[Empty Cloudscape app](empty-vite) | Cloudscape example built with React Router and Vite.| 19 | |[Basic Cloudscape app](basic-vite) | Cloudscape example built with React Router and Vite, featuring a dashboard page, a table page, details page, and an add page.| 20 | |[Fullstack Cloudscape app with CDK and Cognito auth](fullstack-vite-cdk-cognito-auth) | Cloudscape fullstack example built with React Router and Vite, featuring a dashboard page, a table page, details page, and an add page. It is deployable with AWS CDK (Cloud Development Kit). The example deploys the frontend as a static website to an S3 bucket and serves it with Amazon CloudFront. It utilizes Amazon Cognito for authentication and Amplify UI for React for the login user interface. Data is stored in Amazon DynamoDB. The REST API is implemented with Amazon API Gateway and AWS Lambda and uses Powertools for AWS Lambda.| 21 | | [Chat UI for Cloudscape](chat-ui-vite) | Cloudscape example featuring a Chat UI, with a message input field and a list of messages.| 22 | |[Fullstack Chat UI app with CDK and Cognito auth](full-stack-chat-ui-cognito-auth) | Cloudscape fullstack Chat UI example built with React Router and Vite, featuring a chat bot page. It is deployable with AWS CDK (Cloud Development Kit). The example deploys the frontend as a static website to an S3 bucket and serves it with Amazon CloudFront. It utilizes Amazon Cognito for authentication and Amplify UI for React for the login user interface. The REST API is implemented with Amazon API Gateway and AWS Lambda and uses Powertools for AWS Lambda.| 23 | 24 | 25 | # License 26 | 27 | This library is licensed under the MIT-0 License. See the LICENSE file. 28 | 29 | - [License](LICENSE) of the project. 30 | - [Code of Conduct](CODE_OF_CONDUCT.md) of the project. 31 | - [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information. 32 | 33 | # Legal Disclaimer 34 | 35 | You should consider doing your own independent assessment before using the content in this repository for production purposes. This may include (amongst other things) testing, securing, and optimizing the content provided in this repository, based on your specific quality control practices and standards. -------------------------------------------------------------------------------- /assets/aws-exports.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/assets/aws-exports.png -------------------------------------------------------------------------------- /assets/basic-vite-cdk-cognito-auth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/assets/basic-vite-cdk-cognito-auth.png -------------------------------------------------------------------------------- /assets/basic-vite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/assets/basic-vite.png -------------------------------------------------------------------------------- /assets/chat-ui-vite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/assets/chat-ui-vite.png -------------------------------------------------------------------------------- /assets/empty-vite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/assets/empty-vite.png -------------------------------------------------------------------------------- /assets/full-stack-chat-ui-cognito-auth-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/assets/full-stack-chat-ui-cognito-auth-01.png -------------------------------------------------------------------------------- /assets/full-stack-chat-ui-cognito-auth-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/assets/full-stack-chat-ui-cognito-auth-02.png -------------------------------------------------------------------------------- /assets/full-stack-chat-ui-cognito-auth-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/assets/full-stack-chat-ui-cognito-auth-03.png -------------------------------------------------------------------------------- /assets/full-stack-chat-ui-cognito-auth-04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/assets/full-stack-chat-ui-cognito-auth-04.png -------------------------------------------------------------------------------- /assets/fullstack-chat-ui-cognito-auth-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/assets/fullstack-chat-ui-cognito-auth-architecture.png -------------------------------------------------------------------------------- /assets/fullstack-vite-cdk-cognito-auth-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/assets/fullstack-vite-cdk-cognito-auth-01.png -------------------------------------------------------------------------------- /assets/fullstack-vite-cdk-cognito-auth-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/assets/fullstack-vite-cdk-cognito-auth-02.png -------------------------------------------------------------------------------- /assets/fullstack-vite-cdk-cognito-auth-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/assets/fullstack-vite-cdk-cognito-auth-architecture.png -------------------------------------------------------------------------------- /basic-vite/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { browser: true, es2020: true }, 4 | extends: [ 5 | 'eslint:recommended', 6 | 'plugin:@typescript-eslint/recommended', 7 | 'plugin:react-hooks/recommended', 8 | ], 9 | ignorePatterns: ['dist', '.eslintrc.cjs'], 10 | parser: '@typescript-eslint/parser', 11 | plugins: ['react-refresh'], 12 | rules: { 13 | 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }], 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /basic-vite/README.md: -------------------------------------------------------------------------------- 1 | # Basic Cloudscape App 2 | 3 | [https://cloudscape.design/](https://cloudscape.design/) 4 | 5 | Cloudscape is an open source design system for the cloud. Cloudscape offers user interface guidelines, front-end components, design resources, and development tools for building intuitive, engaging, and inclusive user experiences at scale. 6 | 7 | 8 | ![sample](../assets/basic-vite.png "Screenshot") 9 | 10 | 11 | ## Vite.js 12 | 13 | [https://vitejs.dev/](https://vitejs.dev/) 14 | 15 | Vite.js is a modern, fast front-end build tool that significantly improves the developer experience when building web applications. 16 | 17 | ## Development 18 | 1. Clone this repository to your local machine 19 | ```bash 20 | git clone https://github.com/aws-samples/cloudscape-examples 21 | cd cloudscape-examples/basic-vite 22 | ``` 23 | 2. Install the project dependencies by running: 24 | ```bash 25 | npm install 26 | ``` 27 | 3. To start the development server, run: 28 | ```bash 29 | npm run dev 30 | ``` 31 | 32 | This command will start a local development server at ``http://localhost:3000`` (or a different port if 3000 is in use). The server will hot-reload if you make edits to any of the source files. 33 | 34 | ## Building the App 35 | To build the application for production, run: 36 | ```bash 37 | npm run build 38 | ``` 39 | This command will generate a dist folder containing the production build of your app. Vite optimizes your project for the best performance during this process. 40 | 41 | ## Running the App Locally 42 | After building the app, you can serve it locally using: 43 | ```bash 44 | npm run preview 45 | ``` 46 | This command serves the production build from the dist folder, allowing you to preview the app before deployment. -------------------------------------------------------------------------------- /basic-vite/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 17 | 18 | 19 | Example App 20 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /basic-vite/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cloudscape-app", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc && vite build", 9 | "preview": "vite preview", 10 | "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", 11 | "format": "npx prettier --ignore-path .gitignore --write \"**/*.+(tsx|js|ts|json)\"" 12 | }, 13 | "dependencies": { 14 | "@cloudscape-design/components": "^3.0.611", 15 | "@cloudscape-design/design-tokens": "^3.0.35", 16 | "@cloudscape-design/global-styles": "^1.0.27", 17 | "react": "^18.2.0", 18 | "react-dom": "^18.2.0", 19 | "react-router-dom": "^6.22.0" 20 | }, 21 | "devDependencies": { 22 | "@types/react": "^18.2.55", 23 | "@types/react-dom": "^18.2.19", 24 | "@typescript-eslint/eslint-plugin": "^6.21.0", 25 | "@typescript-eslint/parser": "^6.21.0", 26 | "@vitejs/plugin-react": "^4.3.2", 27 | "autoprefixer": "^10.4.17", 28 | "eslint": "^8.56.0", 29 | "eslint-plugin-react-hooks": "^4.6.0", 30 | "eslint-plugin-react-refresh": "^0.4.5", 31 | "postcss": "^8.4.38", 32 | "sass": "^1.75.0", 33 | "typescript": "^5.4.5", 34 | "vite": "^5.4.8" 35 | }, 36 | "overrides": { 37 | "react-virtual": { 38 | "react": "^18.0.0" 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /basic-vite/postcss.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: { 3 | autoprefixer: {}, 4 | }, 5 | }; 6 | -------------------------------------------------------------------------------- /basic-vite/prettier.config.cjs: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line no-undef 2 | module.export = { 3 | semi: true, 4 | trailingComma: "es5", 5 | singleQuote: false, 6 | tabWidth: 2, 7 | useTabs: false, 8 | }; 9 | -------------------------------------------------------------------------------- /basic-vite/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/basic-vite/public/favicon.ico -------------------------------------------------------------------------------- /basic-vite/public/images/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/basic-vite/public/images/android-chrome-192x192.png -------------------------------------------------------------------------------- /basic-vite/public/images/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/basic-vite/public/images/android-chrome-512x512.png -------------------------------------------------------------------------------- /basic-vite/public/images/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/basic-vite/public/images/apple-touch-icon.png -------------------------------------------------------------------------------- /basic-vite/public/images/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/basic-vite/public/images/favicon-16x16.png -------------------------------------------------------------------------------- /basic-vite/public/images/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/basic-vite/public/images/favicon-32x32.png -------------------------------------------------------------------------------- /basic-vite/public/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/basic-vite/public/images/favicon.ico -------------------------------------------------------------------------------- /basic-vite/public/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/basic-vite/public/images/logo.png -------------------------------------------------------------------------------- /basic-vite/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "/", 3 | "start_url": "/", 4 | "name": "Example App", 5 | "short_name": "Example App", 6 | "description": "Example App sample", 7 | "theme_color": "#000000", 8 | "background_color": "#ffffff", 9 | "display": "standalone", 10 | "icons": [ 11 | { 12 | "src": "/images/android-chrome-192x192.png", 13 | "sizes": "192x192", 14 | "type": "image/png" 15 | }, 16 | { 17 | "src": "/images/android-chrome-512x512.png", 18 | "sizes": "512x512", 19 | "type": "image/png" 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /basic-vite/src/app.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | HashRouter, 3 | BrowserRouter, 4 | Routes, 5 | Route, 6 | Outlet, 7 | } from "react-router-dom"; 8 | import { USE_BROWSER_ROUTER } from "./common/constants"; 9 | import GlobalHeader from "./components/global-header"; 10 | import DashboardPage from "./pages/dashboard/dashboard-page"; 11 | import ViewItemPage from "./pages/section1/view-item/view-item-page"; 12 | import AllItemsPage from "./pages/section1/all-items/all-items-page"; 13 | import AddItemPage from "./pages/section1/add-item/add-item-page"; 14 | import NotFound from "./pages/not-found"; 15 | import "./styles/app.scss"; 16 | 17 | export default function App() { 18 | const Router = USE_BROWSER_ROUTER ? BrowserRouter : HashRouter; 19 | 20 | return ( 21 |
22 | 23 | 24 |
 
25 |
26 | 27 | } /> 28 | }> 29 | } /> 30 | } /> 31 | } /> 32 | 33 | } /> 34 | 35 |
36 |
37 |
38 | ); 39 | } 40 | -------------------------------------------------------------------------------- /basic-vite/src/common/api-client/api-client.ts: -------------------------------------------------------------------------------- 1 | import { ItemsApiClient } from "./items-api-client"; 2 | 3 | export class ApiClient { 4 | private _itemsClient: ItemsApiClient | undefined; 5 | 6 | public get items() { 7 | if (!this._itemsClient) { 8 | this._itemsClient = new ItemsApiClient(); 9 | } 10 | 11 | return this._itemsClient; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /basic-vite/src/common/api-client/items-api-client.ts: -------------------------------------------------------------------------------- 1 | import { Item } from "../types"; 2 | import { Utils } from "../utils"; 3 | 4 | export class ItemsApiClient { 5 | async getItems(): Promise { 6 | await Utils.promiseSetTimeout(1000); 7 | 8 | const retValue: Item[] = []; 9 | 10 | for (let i = 0; i < 150; i++) { 11 | retValue.push({ 12 | itemId: i.toString(), 13 | name: `Item ${i}`, 14 | type: `Type ${i}`, 15 | status: i % 10 === 0 ? "warning" : i % 15 === 1 ? "error" : "success", 16 | details: i * 10, 17 | }); 18 | } 19 | 20 | return retValue; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /basic-vite/src/common/constants.ts: -------------------------------------------------------------------------------- 1 | export const APP_NAME = "Example App"; 2 | export const USE_BROWSER_ROUTER = true; 3 | -------------------------------------------------------------------------------- /basic-vite/src/common/helpers/storage-helper.ts: -------------------------------------------------------------------------------- 1 | import { Mode, applyMode } from "@cloudscape-design/global-styles"; 2 | import { NavigationPanelState } from "../types"; 3 | 4 | const PREFIX = "example-app"; 5 | const THEME_STORAGE_NAME = `${PREFIX}-theme`; 6 | const NAVIGATION_PANEL_STATE_STORAGE_NAME = `${PREFIX}-navigation-panel-state`; 7 | 8 | export abstract class StorageHelper { 9 | static getTheme() { 10 | const value = localStorage.getItem(THEME_STORAGE_NAME) ?? Mode.Light; 11 | const theme = value === Mode.Dark ? Mode.Dark : Mode.Light; 12 | 13 | return theme; 14 | } 15 | 16 | static applyTheme(theme: Mode) { 17 | localStorage.setItem(THEME_STORAGE_NAME, theme); 18 | applyMode(theme); 19 | 20 | document.documentElement.style.setProperty( 21 | "--app-color-scheme", 22 | theme === Mode.Dark ? "dark" : "light" 23 | ); 24 | 25 | return theme; 26 | } 27 | 28 | static getNavigationPanelState(): NavigationPanelState { 29 | const value = 30 | localStorage.getItem(NAVIGATION_PANEL_STATE_STORAGE_NAME) ?? 31 | JSON.stringify({ 32 | collapsed: true, 33 | }); 34 | 35 | let state: NavigationPanelState | null = null; 36 | try { 37 | state = JSON.parse(value); 38 | } catch { 39 | state = {}; 40 | } 41 | 42 | return state ?? {}; 43 | } 44 | 45 | static setNavigationPanelState(state: Partial) { 46 | const currentState = this.getNavigationPanelState(); 47 | const newState = { ...currentState, ...state }; 48 | const stateStr = JSON.stringify(newState); 49 | localStorage.setItem(NAVIGATION_PANEL_STATE_STORAGE_NAME, stateStr); 50 | 51 | return newState; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /basic-vite/src/common/helpers/text-helper.ts: -------------------------------------------------------------------------------- 1 | export abstract class TextHelper { 2 | static getTextFilterCounterText(count = 0) { 3 | return `${count} ${count === 1 ? "match" : "matches"}`; 4 | } 5 | 6 | static getHeaderCounterText( 7 | items: ReadonlyArray, 8 | selectedItems: ReadonlyArray | undefined, 9 | ) { 10 | return selectedItems && selectedItems?.length > 0 11 | ? `(${selectedItems.length}/${items.length})` 12 | : `(${items.length})`; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /basic-vite/src/common/hooks/use-navigation-panel-state.ts: -------------------------------------------------------------------------------- 1 | import { useState } from "react"; 2 | import { StorageHelper } from "../helpers/storage-helper"; 3 | import { NavigationPanelState } from "../types"; 4 | 5 | export function useNavigationPanelState(): [ 6 | NavigationPanelState, 7 | (state: Partial) => void, 8 | ] { 9 | const [currentState, setCurrentState] = useState( 10 | StorageHelper.getNavigationPanelState(), 11 | ); 12 | 13 | const onChange = (state: Partial) => { 14 | setCurrentState(StorageHelper.setNavigationPanelState(state)); 15 | }; 16 | 17 | return [currentState, onChange]; 18 | } 19 | -------------------------------------------------------------------------------- /basic-vite/src/common/hooks/use-on-follow.ts: -------------------------------------------------------------------------------- 1 | import { useCallback } from "react"; 2 | import { useNavigate } from "react-router"; 3 | 4 | interface FollowDetail { 5 | external?: boolean; 6 | href?: string; 7 | } 8 | 9 | export function useOnFollow() { 10 | const navigate = useNavigate(); 11 | 12 | return useCallback( 13 | (event: CustomEvent): void => { 14 | if ( 15 | event.detail.external === true || 16 | typeof event.detail.href === "undefined" 17 | ) { 18 | return; 19 | } 20 | 21 | event.preventDefault(); 22 | navigate(event.detail.href); 23 | }, 24 | [navigate], 25 | ); 26 | } 27 | -------------------------------------------------------------------------------- /basic-vite/src/common/i18n/property-filter-i18n-strings.ts: -------------------------------------------------------------------------------- 1 | import { PropertyFilterProps } from "@cloudscape-design/components"; 2 | 3 | export const PropertyFilterI18nStrings: PropertyFilterProps.I18nStrings = { 4 | filteringAriaLabel: "your choice", 5 | dismissAriaLabel: "Dismiss", 6 | 7 | groupValuesText: "Values", 8 | groupPropertiesText: "Properties", 9 | operatorsText: "Operators", 10 | 11 | operationAndText: "and", 12 | operationOrText: "or", 13 | 14 | operatorLessText: "Less than", 15 | operatorLessOrEqualText: "Less than or equal", 16 | operatorGreaterText: "Greater than", 17 | operatorGreaterOrEqualText: "Greater than or equal", 18 | operatorContainsText: "Contains", 19 | operatorDoesNotContainText: "Does not contain", 20 | operatorEqualsText: "Equals", 21 | operatorDoesNotEqualText: "Does not equal", 22 | 23 | editTokenHeader: "Edit filter", 24 | propertyText: "Property", 25 | operatorText: "Operator", 26 | valueText: "Value", 27 | cancelActionText: "Cancel", 28 | applyActionText: "Apply", 29 | allPropertiesLabel: "All properties", 30 | 31 | tokenLimitShowMore: "Show more", 32 | tokenLimitShowFewer: "Show fewer", 33 | clearFiltersText: "Clear filters", 34 | removeTokenButtonAriaLabel: (token) => 35 | `Remove token ${token.propertyKey} ${token.operator} ${token.value}`, 36 | enteredTextLabel: (text) => `Use: "${text}"`, 37 | }; 38 | -------------------------------------------------------------------------------- /basic-vite/src/common/types.ts: -------------------------------------------------------------------------------- 1 | import { StatusIndicatorProps } from "@cloudscape-design/components"; 2 | 3 | export interface NavigationPanelState { 4 | collapsed?: boolean; 5 | collapsedSections?: Record; 6 | } 7 | 8 | export interface Item { 9 | itemId: string; 10 | name: string; 11 | type: string; 12 | status: StatusIndicatorProps.Type; 13 | details: number; 14 | } 15 | -------------------------------------------------------------------------------- /basic-vite/src/common/utils.ts: -------------------------------------------------------------------------------- 1 | export abstract class Utils { 2 | static promiseSetTimeout(duration: number) { 3 | return new Promise((resolve) => { 4 | setTimeout(() => { 5 | resolve("Done"); 6 | }, duration); 7 | }); 8 | } 9 | 10 | static urlSearchParamsToRecord( 11 | params: URLSearchParams 12 | ): Record { 13 | const record: Record = {}; 14 | 15 | for (const [key, value] of params.entries()) { 16 | record[key] = value; 17 | } 18 | 19 | return record; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /basic-vite/src/components/base-app-layout.tsx: -------------------------------------------------------------------------------- 1 | import { AppLayout, AppLayoutProps } from "@cloudscape-design/components"; 2 | import { useNavigationPanelState } from "../common/hooks/use-navigation-panel-state"; 3 | import NavigationPanel from "./navigation-panel"; 4 | 5 | export default function BaseAppLayout(props: AppLayoutProps) { 6 | const [navigationPanelState, setNavigationPanelState] = 7 | useNavigationPanelState(); 8 | 9 | return ( 10 | } 13 | navigationOpen={!navigationPanelState.collapsed} 14 | onNavigationChange={({ detail }) => 15 | setNavigationPanelState({ collapsed: !detail.open }) 16 | } 17 | toolsHide={true} 18 | {...props} 19 | /> 20 | ); 21 | } 22 | -------------------------------------------------------------------------------- /basic-vite/src/components/global-header.tsx: -------------------------------------------------------------------------------- 1 | import { useState } from "react"; 2 | import { TopNavigation } from "@cloudscape-design/components"; 3 | import { Mode } from "@cloudscape-design/global-styles"; 4 | import { StorageHelper } from "../common/helpers/storage-helper"; 5 | import { APP_NAME } from "../common/constants"; 6 | 7 | export default function GlobalHeader() { 8 | const [theme, setTheme] = useState(StorageHelper.getTheme()); 9 | 10 | const onChangeThemeClick = () => { 11 | if (theme === Mode.Dark) { 12 | setTheme(StorageHelper.applyTheme(Mode.Light)); 13 | } else { 14 | setTheme(StorageHelper.applyTheme(Mode.Dark)); 15 | } 16 | }; 17 | 18 | return ( 19 |
23 | 36 |
37 | ); 38 | } 39 | -------------------------------------------------------------------------------- /basic-vite/src/components/navigation-panel.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | SideNavigation, 3 | SideNavigationProps, 4 | } from "@cloudscape-design/components"; 5 | import { useNavigationPanelState } from "../common/hooks/use-navigation-panel-state"; 6 | import { useState } from "react"; 7 | import { useOnFollow } from "../common/hooks/use-on-follow"; 8 | import { APP_NAME } from "../common/constants"; 9 | import { useLocation } from "react-router-dom"; 10 | 11 | export default function NavigationPanel() { 12 | const location = useLocation(); 13 | const onFollow = useOnFollow(); 14 | const [navigationPanelState, setNavigationPanelState] = 15 | useNavigationPanelState(); 16 | 17 | const [items] = useState(() => { 18 | const items: SideNavigationProps.Item[] = [ 19 | { 20 | type: "link", 21 | text: "Dashboard", 22 | href: "/", 23 | }, 24 | { 25 | type: "section", 26 | text: "Section 1", 27 | items: [{ type: "link", text: "Items", href: "/section1" }], 28 | }, 29 | { 30 | type: "section", 31 | text: "Section 2", 32 | items: [ 33 | { type: "link", text: "Item 1", href: "/section2/item1" }, 34 | { type: "link", text: "Item 2", href: "/section2/item2" }, 35 | { type: "link", text: "Item 2", href: "/section2/item3" }, 36 | ], 37 | }, 38 | ]; 39 | 40 | items.push( 41 | { type: "divider" }, 42 | { 43 | type: "link", 44 | text: "Documentation", 45 | href: "https://github.com/aws-samples/cloudscape-examples", 46 | external: true, 47 | } 48 | ); 49 | 50 | return items; 51 | }); 52 | 53 | const onChange = ({ 54 | detail, 55 | }: { 56 | detail: SideNavigationProps.ChangeDetail; 57 | }) => { 58 | const sectionIndex = items.indexOf(detail.item); 59 | setNavigationPanelState({ 60 | collapsedSections: { 61 | ...navigationPanelState.collapsedSections, 62 | [sectionIndex]: !detail.expanded, 63 | }, 64 | }); 65 | }; 66 | 67 | return ( 68 | { 74 | if (value.type === "section") { 75 | const collapsed = 76 | navigationPanelState.collapsedSections?.[idx] === true; 77 | value.defaultExpanded = !collapsed; 78 | } 79 | 80 | return value; 81 | })} 82 | /> 83 | ); 84 | } 85 | -------------------------------------------------------------------------------- /basic-vite/src/components/wrappers/router-button-dropdown.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | ButtonDropdownProps, 3 | ButtonDropdown, 4 | } from "@cloudscape-design/components"; 5 | import { useOnFollow } from "../../common/hooks/use-on-follow"; 6 | 7 | export default function RouterButtonDropdown(props: ButtonDropdownProps) { 8 | const onFollow = useOnFollow(); 9 | 10 | return ; 11 | } 12 | -------------------------------------------------------------------------------- /basic-vite/src/components/wrappers/router-button.tsx: -------------------------------------------------------------------------------- 1 | import { ButtonProps, Button } from "@cloudscape-design/components"; 2 | import { useOnFollow } from "../../common/hooks/use-on-follow"; 3 | 4 | export default function RouterButton(props: ButtonProps) { 5 | const onFollow = useOnFollow(); 6 | 7 | return 74 | 75 | } 76 | errorText={globalError} 77 | > 78 | Item Configuration} 80 | > 81 | 82 | 83 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | } 95 | /> 96 | ); 97 | } 98 | -------------------------------------------------------------------------------- /basic-vite/src/pages/section1/all-items/all-items-header.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | Button, 3 | Header, 4 | HeaderProps, 5 | SpaceBetween, 6 | } from "@cloudscape-design/components"; 7 | import RouterButton from "../../../components/wrappers/router-button"; 8 | import { useNavigate } from "react-router-dom"; 9 | import { Item } from "../../../common/types"; 10 | 11 | interface AllItemsPageHeaderProps extends HeaderProps { 12 | title?: string; 13 | createButtonText?: string; 14 | selectedItems: readonly Item[]; 15 | } 16 | 17 | export function AllItemsPageHeader({ 18 | title = "Items", 19 | ...props 20 | }: AllItemsPageHeaderProps) { 21 | const navigate = useNavigate(); 22 | 23 | return ( 24 |
28 |
57 | ); 58 | } 59 | -------------------------------------------------------------------------------- /basic-vite/src/pages/section1/all-items/all-items-page.tsx: -------------------------------------------------------------------------------- 1 | import { BreadcrumbGroup } from "@cloudscape-design/components"; 2 | import { APP_NAME } from "../../../common/constants"; 3 | import { useOnFollow } from "../../../common/hooks/use-on-follow"; 4 | import BaseAppLayout from "../../../components/base-app-layout"; 5 | import AllItemsTable from "./all-items-table"; 6 | 7 | export default function AllItemsPage() { 8 | const onFollow = useOnFollow(); 9 | 10 | return ( 11 | 26 | } 27 | content={} 28 | /> 29 | ); 30 | } 31 | -------------------------------------------------------------------------------- /basic-vite/src/styles/app.scss: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing: border-box; 3 | } 4 | 5 | :root { 6 | --app-color-scheme: light; 7 | color-scheme: var(--app-color-scheme); 8 | } 9 | 10 | html, 11 | body, 12 | #root, 13 | div[data-amplify-authenticator], 14 | div[data-amplify-theme] { 15 | height: 100%; 16 | } 17 | 18 | body { 19 | background-color: #ffffff; 20 | overflow-y: scroll; 21 | } 22 | 23 | body.awsui-dark-mode { 24 | background-color: #0e1b2a; 25 | } 26 | -------------------------------------------------------------------------------- /basic-vite/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /basic-vite/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | "jsx": "react-jsx", 16 | 17 | /* Linting */ 18 | "strict": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noFallthroughCasesInSwitch": true 22 | }, 23 | "include": ["src"], 24 | "references": [{ "path": "./tsconfig.node.json" }] 25 | } 26 | -------------------------------------------------------------------------------- /basic-vite/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true, 8 | "strict": true 9 | }, 10 | "include": ["vite.config.ts"] 11 | } 12 | -------------------------------------------------------------------------------- /basic-vite/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vite"; 2 | import react from "@vitejs/plugin-react"; 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | server: { 8 | port: 3000, 9 | }, 10 | }); 11 | -------------------------------------------------------------------------------- /chat-ui-vite/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { browser: true, es2020: true }, 4 | extends: [ 5 | 'eslint:recommended', 6 | 'plugin:@typescript-eslint/recommended', 7 | 'plugin:react-hooks/recommended', 8 | ], 9 | ignorePatterns: ['dist', '.eslintrc.cjs'], 10 | parser: '@typescript-eslint/parser', 11 | plugins: ['react-refresh'], 12 | rules: { 13 | 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }], 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /chat-ui-vite/README.md: -------------------------------------------------------------------------------- 1 | # Chat UI Cloudscape App 2 | 3 | [https://cloudscape.design/](https://cloudscape.design/) 4 | 5 | Cloudscape is an open source design system for the cloud. Cloudscape offers user interface guidelines, front-end components, design resources, and development tools for building intuitive, engaging, and inclusive user experiences at scale. 6 | 7 | 8 | ![sample](../assets/chat-ui-vite.png "Screenshot") 9 | 10 | 11 | ## Vite.js 12 | 13 | [https://vitejs.dev/](https://vitejs.dev/) 14 | 15 | Vite.js is a modern, fast front-end build tool that significantly improves the developer experience when building web applications. 16 | 17 | ## Development 18 | 1. Clone this repository to your local machine 19 | ```bash 20 | git clone https://github.com/aws-samples/cloudscape-examples 21 | cd cloudscape-examples/chat-ui-vite 22 | ``` 23 | 2. Install the project dependencies by running: 24 | ```bash 25 | npm install 26 | ``` 27 | 3. To start the development server, run: 28 | ```bash 29 | npm run dev 30 | ``` 31 | 32 | This command will start a local development server at ``http://localhost:3000`` (or a different port if 3000 is in use). The server will hot-reload if you make edits to any of the source files. 33 | 34 | ## Building the App 35 | To build the application for production, run: 36 | ```bash 37 | npm run build 38 | ``` 39 | This command will generate a dist folder containing the production build of your app. Vite optimizes your project for the best performance during this process. 40 | 41 | ## Running the App Locally 42 | After building the app, you can serve it locally using: 43 | ```bash 44 | npm run preview 45 | ``` 46 | This command serves the production build from the dist folder, allowing you to preview the app before deployment. -------------------------------------------------------------------------------- /chat-ui-vite/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 17 | 18 | 19 | Example App 20 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /chat-ui-vite/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cloudscape-app", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc && vite build", 9 | "preview": "vite preview", 10 | "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", 11 | "format": "npx prettier --ignore-path .gitignore --write \"**/*.+(tsx|js|ts|json)\"" 12 | }, 13 | "dependencies": { 14 | "@cloudscape-design/components": "^3.0.611", 15 | "@cloudscape-design/design-tokens": "^3.0.35", 16 | "@cloudscape-design/global-styles": "^1.0.27", 17 | "react": "^18.2.0", 18 | "react-dom": "^18.2.0", 19 | "react-markdown": "^9.0.1", 20 | "react-router-dom": "^6.22.0", 21 | "react-textarea-autosize": "^8.5.3", 22 | "remark-gfm": "^4.0.0" 23 | }, 24 | "devDependencies": { 25 | "@types/react": "^18.2.55", 26 | "@types/react-dom": "^18.2.19", 27 | "@typescript-eslint/eslint-plugin": "^6.21.0", 28 | "@typescript-eslint/parser": "^6.21.0", 29 | "@vitejs/plugin-react": "^4.3.2", 30 | "autoprefixer": "^10.4.17", 31 | "eslint": "^8.56.0", 32 | "eslint-plugin-react-hooks": "^4.6.0", 33 | "eslint-plugin-react-refresh": "^0.4.5", 34 | "postcss": "^8.4.35", 35 | "sass": "^1.70.0", 36 | "typescript": "^5.2.2", 37 | "vite": "^5.4.8" 38 | }, 39 | "overrides": { 40 | "react-virtual": { 41 | "react": "^18.0.0" 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /chat-ui-vite/postcss.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: { 3 | autoprefixer: {}, 4 | }, 5 | }; 6 | -------------------------------------------------------------------------------- /chat-ui-vite/prettier.config.cjs: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line no-undef 2 | module.export = { 3 | semi: true, 4 | trailingComma: "es5", 5 | singleQuote: false, 6 | tabWidth: 2, 7 | useTabs: false, 8 | }; 9 | -------------------------------------------------------------------------------- /chat-ui-vite/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/chat-ui-vite/public/favicon.ico -------------------------------------------------------------------------------- /chat-ui-vite/public/images/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/chat-ui-vite/public/images/android-chrome-192x192.png -------------------------------------------------------------------------------- /chat-ui-vite/public/images/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/chat-ui-vite/public/images/android-chrome-512x512.png -------------------------------------------------------------------------------- /chat-ui-vite/public/images/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/chat-ui-vite/public/images/apple-touch-icon.png -------------------------------------------------------------------------------- /chat-ui-vite/public/images/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/chat-ui-vite/public/images/favicon-16x16.png -------------------------------------------------------------------------------- /chat-ui-vite/public/images/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/chat-ui-vite/public/images/favicon-32x32.png -------------------------------------------------------------------------------- /chat-ui-vite/public/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/chat-ui-vite/public/images/favicon.ico -------------------------------------------------------------------------------- /chat-ui-vite/public/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cloudscape-examples/35055cf8fb197302784028998a9d8c3c55acea78/chat-ui-vite/public/images/logo.png -------------------------------------------------------------------------------- /chat-ui-vite/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "/", 3 | "start_url": "/", 4 | "name": "Example App", 5 | "short_name": "Example App", 6 | "description": "Example App sample", 7 | "theme_color": "#000000", 8 | "background_color": "#ffffff", 9 | "display": "standalone", 10 | "icons": [ 11 | { 12 | "src": "/images/android-chrome-192x192.png", 13 | "sizes": "192x192", 14 | "type": "image/png" 15 | }, 16 | { 17 | "src": "/images/android-chrome-512x512.png", 18 | "sizes": "512x512", 19 | "type": "image/png" 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /chat-ui-vite/src/app.tsx: -------------------------------------------------------------------------------- 1 | import { HashRouter, BrowserRouter, Routes, Route } from "react-router-dom"; 2 | import { USE_BROWSER_ROUTER } from "./common/constants"; 3 | import GlobalHeader from "./components/global-header"; 4 | import NotFound from "./pages/not-found"; 5 | import ChatPage from "./pages/chat-page"; 6 | import "./styles/app.scss"; 7 | 8 | export default function App() { 9 | const Router = USE_BROWSER_ROUTER ? BrowserRouter : HashRouter; 10 | 11 | return ( 12 |
13 | 14 | 15 |
 
16 |
17 | 18 | } /> 19 | } /> 20 | 21 |
22 |
23 |
24 | ); 25 | } 26 | -------------------------------------------------------------------------------- /chat-ui-vite/src/common/constants.ts: -------------------------------------------------------------------------------- 1 | export const APP_NAME = "Example App"; 2 | export const USE_BROWSER_ROUTER = true; 3 | -------------------------------------------------------------------------------- /chat-ui-vite/src/common/helpers/storage-helper.ts: -------------------------------------------------------------------------------- 1 | import { Mode, applyMode } from "@cloudscape-design/global-styles"; 2 | import { NavigationPanelState } from "../types"; 3 | 4 | const PREFIX = "example-app"; 5 | const THEME_STORAGE_NAME = `${PREFIX}-theme`; 6 | const NAVIGATION_PANEL_STATE_STORAGE_NAME = `${PREFIX}-navigation-panel-state`; 7 | 8 | export abstract class StorageHelper { 9 | static getTheme() { 10 | const value = localStorage.getItem(THEME_STORAGE_NAME) ?? Mode.Light; 11 | const theme = value === Mode.Dark ? Mode.Dark : Mode.Light; 12 | 13 | return theme; 14 | } 15 | 16 | static applyTheme(theme: Mode) { 17 | localStorage.setItem(THEME_STORAGE_NAME, theme); 18 | applyMode(theme); 19 | 20 | document.documentElement.style.setProperty( 21 | "--app-color-scheme", 22 | theme === Mode.Dark ? "dark" : "light" 23 | ); 24 | 25 | return theme; 26 | } 27 | 28 | static getNavigationPanelState(): NavigationPanelState { 29 | const value = 30 | localStorage.getItem(NAVIGATION_PANEL_STATE_STORAGE_NAME) ?? 31 | JSON.stringify({ 32 | collapsed: true, 33 | }); 34 | 35 | let state: NavigationPanelState | null = null; 36 | try { 37 | state = JSON.parse(value); 38 | } catch { 39 | state = {}; 40 | } 41 | 42 | return state ?? {}; 43 | } 44 | 45 | static setNavigationPanelState(state: Partial) { 46 | const currentState = this.getNavigationPanelState(); 47 | const newState = { ...currentState, ...state }; 48 | const stateStr = JSON.stringify(newState); 49 | localStorage.setItem(NAVIGATION_PANEL_STATE_STORAGE_NAME, stateStr); 50 | 51 | return newState; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /chat-ui-vite/src/common/hooks/use-navigation-panel-state.ts: -------------------------------------------------------------------------------- 1 | import { useState } from "react"; 2 | import { StorageHelper } from "../helpers/storage-helper"; 3 | import { NavigationPanelState } from "../types"; 4 | 5 | export function useNavigationPanelState(): [ 6 | NavigationPanelState, 7 | (state: Partial) => void, 8 | ] { 9 | const [currentState, setCurrentState] = useState( 10 | StorageHelper.getNavigationPanelState(), 11 | ); 12 | 13 | const onChange = (state: Partial) => { 14 | setCurrentState(StorageHelper.setNavigationPanelState(state)); 15 | }; 16 | 17 | return [currentState, onChange]; 18 | } 19 | -------------------------------------------------------------------------------- /chat-ui-vite/src/common/hooks/use-on-follow.ts: -------------------------------------------------------------------------------- 1 | import { useCallback } from "react"; 2 | import { useNavigate } from "react-router"; 3 | 4 | interface FollowDetail { 5 | external?: boolean; 6 | href?: string; 7 | } 8 | 9 | export function useOnFollow() { 10 | const navigate = useNavigate(); 11 | 12 | return useCallback( 13 | (event: CustomEvent): void => { 14 | if ( 15 | event.detail.external === true || 16 | typeof event.detail.href === "undefined" 17 | ) { 18 | return; 19 | } 20 | 21 | event.preventDefault(); 22 | navigate(event.detail.href); 23 | }, 24 | [navigate], 25 | ); 26 | } 27 | -------------------------------------------------------------------------------- /chat-ui-vite/src/common/types.ts: -------------------------------------------------------------------------------- 1 | export interface NavigationPanelState { 2 | collapsed?: boolean; 3 | collapsedSections?: Record; 4 | } 5 | -------------------------------------------------------------------------------- /chat-ui-vite/src/components/base-app-layout.tsx: -------------------------------------------------------------------------------- 1 | import { AppLayout, AppLayoutProps } from "@cloudscape-design/components"; 2 | import { useNavigationPanelState } from "../common/hooks/use-navigation-panel-state"; 3 | import NavigationPanel from "./navigation-panel"; 4 | 5 | export default function BaseAppLayout(props: AppLayoutProps) { 6 | const [navigationPanelState, setNavigationPanelState] = 7 | useNavigationPanelState(); 8 | 9 | return ( 10 | } 13 | navigationOpen={!navigationPanelState.collapsed} 14 | onNavigationChange={({ detail }) => 15 | setNavigationPanelState({ collapsed: !detail.open }) 16 | } 17 | toolsHide={true} 18 | {...props} 19 | /> 20 | ); 21 | } 22 | -------------------------------------------------------------------------------- /chat-ui-vite/src/components/chat-ui/chat-ui-message-list.tsx: -------------------------------------------------------------------------------- 1 | import { SpaceBetween } from "@cloudscape-design/components"; 2 | import { ChatMessage } from "./types"; 3 | import ChatUIMessage from "./chat-ui-message"; 4 | 5 | export interface ChatUIMessageListProps { 6 | messages?: ChatMessage[]; 7 | showCopyButton?: boolean; 8 | } 9 | 10 | export default function ChatUIMessageList(props: ChatUIMessageListProps) { 11 | const messages = props.messages || []; 12 | 13 | return ( 14 | 15 | {messages.map((message, idx) => ( 16 | 21 | ))} 22 | 23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /chat-ui-vite/src/components/chat-ui/chat-ui.tsx: -------------------------------------------------------------------------------- 1 | import { StatusIndicator } from "@cloudscape-design/components"; 2 | import { ChatMessage } from "./types"; 3 | import ChatUIInputPanel from "./chat-ui-input-panel"; 4 | import { useEffect } from "react"; 5 | import ChatUIMessageList from "./chat-ui-message-list"; 6 | import styles from "../../styles/chat-ui.module.scss"; 7 | 8 | export interface ChatUIProps { 9 | loading?: boolean; 10 | running?: boolean; 11 | messages?: ChatMessage[]; 12 | welcomeText?: string; 13 | inputPlaceholderText?: string; 14 | sendButtonText?: string; 15 | showCopyButton?: boolean; 16 | onSendMessage?: (message: string) => void; 17 | } 18 | 19 | export abstract class ChatScrollState { 20 | static userHasScrolled = false; 21 | static skipNextScrollEvent = false; 22 | static skipNextHistoryUpdate = false; 23 | } 24 | 25 | export function ChatUI(props: ChatUIProps) { 26 | useEffect(() => { 27 | const onWindowScroll = () => { 28 | if (ChatScrollState.skipNextScrollEvent) { 29 | ChatScrollState.skipNextScrollEvent = false; 30 | return; 31 | } 32 | 33 | const isScrollToTheEnd = 34 | Math.abs( 35 | window.innerHeight + 36 | window.scrollY - 37 | document.documentElement.scrollHeight 38 | ) <= 10; 39 | 40 | if (!isScrollToTheEnd) { 41 | ChatScrollState.userHasScrolled = true; 42 | } else { 43 | ChatScrollState.userHasScrolled = false; 44 | } 45 | }; 46 | 47 | window.addEventListener("scroll", onWindowScroll); 48 | 49 | return () => { 50 | window.removeEventListener("scroll", onWindowScroll); 51 | }; 52 | }, []); 53 | 54 | return ( 55 |
56 | 60 |
61 | {props.messages?.length === 0 && !props.loading && ( 62 |
{props.welcomeText ?? "ChatBot"}
63 | )} 64 | {props.loading && ( 65 |
66 | Loading 67 |
68 | )} 69 |
70 |
71 | 72 |
73 |
74 | ); 75 | } 76 | -------------------------------------------------------------------------------- /chat-ui-vite/src/components/chat-ui/types.tsx: -------------------------------------------------------------------------------- 1 | export enum ChatMessageType { 2 | AI = "ai", 3 | Human = "human", 4 | } 5 | 6 | export interface ChatMessage { 7 | type: ChatMessageType; 8 | content: string; 9 | } 10 | -------------------------------------------------------------------------------- /chat-ui-vite/src/components/global-header.tsx: -------------------------------------------------------------------------------- 1 | import { useState } from "react"; 2 | import { TopNavigation } from "@cloudscape-design/components"; 3 | import { Mode } from "@cloudscape-design/global-styles"; 4 | import { StorageHelper } from "../common/helpers/storage-helper"; 5 | import { APP_NAME } from "../common/constants"; 6 | 7 | export default function GlobalHeader() { 8 | const [theme, setTheme] = useState(StorageHelper.getTheme()); 9 | 10 | const onChangeThemeClick = () => { 11 | if (theme === Mode.Dark) { 12 | setTheme(StorageHelper.applyTheme(Mode.Light)); 13 | } else { 14 | setTheme(StorageHelper.applyTheme(Mode.Dark)); 15 | } 16 | }; 17 | 18 | return ( 19 |
23 | 36 |
37 | ); 38 | } 39 | -------------------------------------------------------------------------------- /chat-ui-vite/src/components/navigation-panel.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | SideNavigation, 3 | SideNavigationProps, 4 | } from "@cloudscape-design/components"; 5 | import { useNavigationPanelState } from "../common/hooks/use-navigation-panel-state"; 6 | import { useState } from "react"; 7 | import { useOnFollow } from "../common/hooks/use-on-follow"; 8 | import { APP_NAME } from "../common/constants"; 9 | import { useLocation } from "react-router-dom"; 10 | 11 | export default function NavigationPanel() { 12 | const location = useLocation(); 13 | const onFollow = useOnFollow(); 14 | const [navigationPanelState, setNavigationPanelState] = 15 | useNavigationPanelState(); 16 | 17 | const [items] = useState(() => { 18 | const items: SideNavigationProps.Item[] = [ 19 | { 20 | type: "link", 21 | text: "Chat", 22 | href: "/", 23 | }, 24 | { 25 | type: "section", 26 | text: "Section", 27 | items: [ 28 | { type: "link", text: "Item 1", href: "/section/item1" }, 29 | { type: "link", text: "Item 2", href: "/section/item2" }, 30 | { type: "link", text: "Item 2", href: "/section/item3" }, 31 | ], 32 | }, 33 | ]; 34 | 35 | items.push( 36 | { type: "divider" }, 37 | { 38 | type: "link", 39 | text: "Documentation", 40 | href: "https://github.com/aws-samples/cloudscape-examples", 41 | external: true, 42 | } 43 | ); 44 | 45 | return items; 46 | }); 47 | 48 | const onChange = ({ 49 | detail, 50 | }: { 51 | detail: SideNavigationProps.ChangeDetail; 52 | }) => { 53 | const sectionIndex = items.indexOf(detail.item); 54 | setNavigationPanelState({ 55 | collapsedSections: { 56 | ...navigationPanelState.collapsedSections, 57 | [sectionIndex]: !detail.expanded, 58 | }, 59 | }); 60 | }; 61 | 62 | return ( 63 | { 69 | if (value.type === "section") { 70 | const collapsed = 71 | navigationPanelState.collapsedSections?.[idx] === true; 72 | value.defaultExpanded = !collapsed; 73 | } 74 | 75 | return value; 76 | })} 77 | /> 78 | ); 79 | } 80 | -------------------------------------------------------------------------------- /chat-ui-vite/src/components/wrappers/router-button-dropdown.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | ButtonDropdownProps, 3 | ButtonDropdown, 4 | } from "@cloudscape-design/components"; 5 | import { useOnFollow } from "../../common/hooks/use-on-follow"; 6 | 7 | export default function RouterButtonDropdown(props: ButtonDropdownProps) { 8 | const onFollow = useOnFollow(); 9 | 10 | return ; 11 | } 12 | -------------------------------------------------------------------------------- /chat-ui-vite/src/components/wrappers/router-button.tsx: -------------------------------------------------------------------------------- 1 | import { ButtonProps, Button } from "@cloudscape-design/components"; 2 | import { useOnFollow } from "../../common/hooks/use-on-follow"; 3 | 4 | export default function RouterButton(props: ButtonProps) { 5 | const onFollow = useOnFollow(); 6 | 7 | return 30 | 37 | 38 | 39 | } 40 | > 41 | {props.item && ( 42 | 43 | 44 | Permanently delete item{" "} 45 | 46 | {props.item.name} 47 | 48 | ? You can't undo this action. 49 | 50 | Item Id: {props.item.itemId} 51 | 52 | Proceeding with this action will delete the item. 53 | 54 | 55 | )} 56 | 57 | ); 58 | } 59 | -------------------------------------------------------------------------------- /fullstack-vite-cdk-cognito-auth/user-interface/src/components/navigation-panel.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | SideNavigation, 3 | SideNavigationProps, 4 | } from "@cloudscape-design/components"; 5 | import { useNavigationPanelState } from "../common/hooks/use-navigation-panel-state"; 6 | import { useState } from "react"; 7 | import { useOnFollow } from "../common/hooks/use-on-follow"; 8 | import { APP_NAME } from "../common/constants"; 9 | import { useLocation } from "react-router-dom"; 10 | 11 | export default function NavigationPanel() { 12 | const location = useLocation(); 13 | const onFollow = useOnFollow(); 14 | const [navigationPanelState, setNavigationPanelState] = 15 | useNavigationPanelState(); 16 | 17 | const [items] = useState(() => { 18 | const items: SideNavigationProps.Item[] = [ 19 | { 20 | type: "link", 21 | text: "Dashboard", 22 | href: "/", 23 | }, 24 | { 25 | type: "section", 26 | text: "Section 1", 27 | items: [{ type: "link", text: "Items", href: "/section1" }], 28 | }, 29 | { 30 | type: "section", 31 | text: "Section 2", 32 | items: [ 33 | { type: "link", text: "Item 1", href: "/section2/item1" }, 34 | { type: "link", text: "Item 2", href: "/section2/item2" }, 35 | { type: "link", text: "Item 2", href: "/section2/item3" }, 36 | ], 37 | }, 38 | ]; 39 | 40 | items.push( 41 | { type: "divider" }, 42 | { 43 | type: "link", 44 | text: "Documentation", 45 | href: "https://github.com/aws-samples/cloudscape-examples", 46 | external: true, 47 | } 48 | ); 49 | 50 | return items; 51 | }); 52 | 53 | const onChange = ({ 54 | detail, 55 | }: { 56 | detail: SideNavigationProps.ChangeDetail; 57 | }) => { 58 | const sectionIndex = items.indexOf(detail.item); 59 | setNavigationPanelState({ 60 | collapsedSections: { 61 | ...navigationPanelState.collapsedSections, 62 | [sectionIndex]: !detail.expanded, 63 | }, 64 | }); 65 | }; 66 | 67 | return ( 68 | { 74 | if (value.type === "section") { 75 | const collapsed = 76 | navigationPanelState.collapsedSections?.[idx] === true; 77 | value.defaultExpanded = !collapsed; 78 | } 79 | 80 | return value; 81 | })} 82 | /> 83 | ); 84 | } 85 | -------------------------------------------------------------------------------- /fullstack-vite-cdk-cognito-auth/user-interface/src/components/wrappers/router-button-dropdown.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | ButtonDropdownProps, 3 | ButtonDropdown, 4 | } from "@cloudscape-design/components"; 5 | import { useOnFollow } from "../../common/hooks/use-on-follow"; 6 | 7 | export default function RouterButtonDropdown(props: ButtonDropdownProps) { 8 | const onFollow = useOnFollow(); 9 | 10 | return ; 11 | } 12 | -------------------------------------------------------------------------------- /fullstack-vite-cdk-cognito-auth/user-interface/src/components/wrappers/router-button.tsx: -------------------------------------------------------------------------------- 1 | import { ButtonProps, Button } from "@cloudscape-design/components"; 2 | import { useOnFollow } from "../../common/hooks/use-on-follow"; 3 | 4 | export default function RouterButton(props: ButtonProps) { 5 | const onFollow = useOnFollow(); 6 | 7 | return