こんにちは、LINE上で動くおくすり連絡帳Pocket Musubi というサービスを開発している種岡です
早いもので入社してから3年が経ちました
会社の成長と共に取り扱うサービスも増え、今では12以上の開発グループが存在しています
誰がどのチームなのかを把握するのが非常に難しい、また、どのチームがどのサービスを担当するのか把握できないという声が寄せられ、チーム間のコミュニケーションの障害になっているという課題感が浮かび上がりました
この課題に対して、チーム毎のポータルページを社内Wikiで作成するという運動が始まりました
そこで、チームポータルページを社内WikiではなくAmplify Studio
を使って作れたら面白そうだなと思い立ち筆をとりました
チームポータルとしては以下のようなReactベースのウェブページを作成することができました
Amplify Studioを使うためAWSアカウントを事前に作成しておいてください
また、Figmaのアカウントを作成し必要なコンポーネントを事前に作成しておいてください
筆者はFigma初心者ですが、上記のような簡単なコンポーネントを作るぐらいであればチュートリアルを見ながら作成できました
Auto Layoutは最高ですね!
今回利用するAmplify StudioはWebアプリケーションを最小限のコーディングで開発ができるローコード開発ツールです
こちらの記事の言葉をお借りすると
になります
今回構築した全体像はざっくり以下のようになります
AWS ConsoleからAmplifyのトップページ下部に表示されるでAmplify Studio
の枠から使用を開始する
ボタンを押します
アプリケーション名を登録します
アプリケーションが登録されたら以下の画面になるので、Studioを起動する
ボタンを押します
するとAmplify Studioのホームが表示されます
左ナビゲーションバーのSet up
の中のData
をクリックすると登録フォームが表示されます
今回チームメンバーの詳細情報をDBで管理してみます
そのためのモデルを作成します(Add model
をクリックして次に進みます)
モデルの名前とメンバーの画像へのパス、名前、自己紹介URL、コメントをフィールドとして登録します
Save and Deploy
を押すとデプロイが開始されます (DynamoDB + AppSyncがデプロイされます)
デプロイが終わると自分のアプリケーションに組み込めるよう手順が表示されます
amplifyコマンドを実行してリソースをpullしてくること、CURD操作のサンプルコードが利用したい言語で表示されるようになっています
とりあえず、Reactアプリへの反映は後で行うのでスキップして次に進みます
メンバーを登録する箱ができたので実データを登録してきます
左サイドバーからManage
の中のContent
を選択すると以下のフォームが表示されるので、必要な情報を入力します
Markdown形式による入力ができるのも良いですね
データ登録が終わったら次にFigmaとの連携作業に移ります
左サイドバーのDesign
のUI Library
をクリックすし、画面右上にあるSync with Figma
ボタンを押します
連携したいFigmaのURLを入力してくださいと表示されます
Figmaを起動してヘッダーの右にあるShare
からURLを取得できます
同期処理が完了するとFigmaで作成したコンポーネントをAmplifyに取り込むかどうかを聞かれるので、Acceptしていきます
すると、Amplify側にFigmaのコンポーネントが表示されます
次にこのコンポーネントデータに対して、さきほど登録したデータをアタッチします
右上のConfigure
ボタンを押して、コンポーネントの編集画面を表示させます
以下の画面の左側にコンポーネントの要素が、右側のカラムにデータの連携先を登録できるようになっています
各要素に対して適切なフィールドをアタッチします
でき上がったら、右上にあるCreate collection
してみます
すると今度は自動でページ一覧用のリスト表示用のコンポーネントが生成されました
左側のLayout部分でデザインを微調整します
検索ボックスやページネーションの追加も1クリックできるのが良いですね
同じ要領で、Figmaでコンポーネントを作成し、Amplify Studio上で同期し、UI Libraryで微調整という手順を繰り返してウェブページの要素を作成します
上記の作業で、FigmaのデザインソースをAmplify上でReactコードとして出力できる状態になっています
ここでは最後の仕上げとして、Reactアプリを新規作成し、対象のコンポーネントを使えるようにします
手順をまとめると以下になります
ローカルの開発環境にてcreate-react-app
でReactアプリを新規作成します
npx create-react-app kusabi-team-introduction
Amplify Studioに戻ってUI Library
から適当なコンポーネントを選択し、画面下部にあるGet component code
をクリックすると以下のようなモーダルが表示されます
こちらの手順に従い、手元のReactにFigmaで作ったコンポーネントのソースを反映させていきます
amplify pull--appId xxxxxx--envName staging⠏ Confirm loginin the browser or manually pastein your CLI login key:✔ Successfully received Amplify Studio tokens.Amplify AppID found: xxxxxx. Amplify App name is: kusabi-team-introductionBackend environment staging foundin Amplify Console app: kusabi-team-introduction? Choose your default editor: Visual Studio Code? Choose thetype of app that you're building javascriptPlease tell us about your project? What javascript framework are you using react? Source Directory Path: src? Distribution Directory Path: build? Build Command: npm run-script build? Start Command: npm run-script start✔ Synced UI components.:white_check_mark: GraphQL schema compiled successfully.Edit your schema at /Users/hoge/Work/test/kusabi-team-introduction/amplify/backend/api/kusabiteamintroduction/schema.graphql or place .graphql files in a directory at /Users/hoge/Work/test/kusabi-team-introduction/amplify/backend/api/kusabiteamintroduction/schemaSuccessfully generated models. Generated models can be found in /Users/hoge/Work/test/kusabi-team-introduction/src? Do you plan on modifying this backend? Yes⠼ Fetching updates to backend environment: staging from the cloud.:white_check_mark: GraphQL schema compiled successfully.Edit your schema at /Users/hoge/Work/test/kusabi-team-introduction/amplify/backend/api/kusabiteamintroduction/schema.graphql or place .graphql files in a directory at /Users/hoge/Work/test/kusabi-team-introduction/amplify/backend/api/kusabiteamintroduction/schema✔ Successfully pulled backend environment staging from the cloud.:white_check_mark:Successfully pulled backend environment staging from the cloud.Run'amplify pull' to sync future upstream changes.
手順に従いindex.jsファイルを修正します
import React from 'react';import ReactDOM from 'react-dom/client';import './index.css';import App from './App';import reportWebVitals from './reportWebVitals';import Amplify from 'aws-amplify';import "@aws-amplify/ui-react/styles.css";import {AmplifyProvider} from "@aws-amplify/ui-react";import awsconfig from './aws-exports';Amplify.configure(awsconfig);const root = ReactDOM.createRoot(document.getElementById('root'));root.render( <AmplifyProvider> <App /> </AmplifyProvider>);
手順を参考に対象のコンポーネントを読み込み利用するよう書き換えます
import './App.css';import { ComponentCollection, ComponentMission,} from './ui-components';function App() { return ( <div className="App"> <ComponentMission /> <br/> <ComponentCollection /> </div> );}export default App;
以下のコマンドで、Figmaで作成したコンポーネントがReact上で動くことを確認できるかと思います
npmstart
以降は
Figma側で修正
→Amplify Studioで取り込み
→amplify pull コマンドでソースコードとして取得
→React側で組み込み
を繰り返すことでブラッシュアップします
追加で、でき上がったチームポータルサイトを皆に見て欲しいのでAmplifyにホスティングします
コマンド2つ実行するだけでできてしまうのが良いですね
ホスティング手段は今回手動にしています(GitHub連携など他の方法でよりDXは向上すると思います)
amplify add hosting✔ Select the plugin module to execute · Hosting with Amplify Console(Managed hosting with custom domains, Continuous deployment)? Choose atype Manual deploymentYou can now publish your app using the following command:Command: amplify publish
publishが完了すると最後にURLが表示されるのでブラウザに対象のURLを入力して確認します
amplify publish⠙ Fetching updates to backend environment: staging from the cloud.:white_check_mark: GraphQL schema compiled successfully.Edit your schema at /Users/hoge/Work/test/kusabi-team-introduction/amplify/backend/api/kusabiteamintroduction/schema.graphql or place .graphql filesin a directory at /Users/hoge/Work/test/kusabi-team-introduction/amplify/backend/api/kusabiteamintroduction/schema✔ Successfully pulled backend environment staging from the cloud. Current Environment: staging┌──────────┬────────────────────────┬───────────┬───────────────────┐│ Category │ Resource name │ Operation │ Provider plugin │├──────────┼────────────────────────┼───────────┼───────────────────┤│ Hosting │ amplifyhosting │ Create │ awscloudformation │├──────────┼────────────────────────┼───────────┼───────────────────┤│ Api │ kusabiteamintroduction │ No Change │ awscloudformation │└──────────┴────────────────────────┴───────────┴───────────────────┘? Are you sure you want tocontinue? YesDeployment completed.Deployed root stack kusabiteamintroducti[========================================]3/3 amplify-kusabiteamintroducti-… AWS::CloudFormation::Stack UPDATE_COMPLETE Wed Sep212022 15:33:03… apikusabiteamintroduction AWS::CloudFormation::Stack UPDATE_COMPLETE Wed Sep212022 15:32:48… hostingamplifyhosting AWS::CloudFormation::Stack CREATE_COMPLETE Wed Sep212022 15:32:38…Deployed hosting amplifyhosting[========================================]1/1 AmplifyBranch AWS::Amplify::Branch CREATE_COMPLETE Wed Sep212022 15:32:35…GraphQL transformer version:2Publish startedfor amplifyhosting> kusabi-team-introduction@0.1.0 build> react-scripts buildCreating an optimized production build...Compiled successfully.File sizes after gzip:285.75 kB build/static/js/main.00e9bd69.js30.24 kB build/static/css/main.70aba177.css1.79 kB build/static/js/787.21a66330.chunk.jsThe project was built assuming it is hosted at /.You can control this with the homepage fieldin your package.json.The build folder is ready to be deployed.You may serve it with a static server: npm install-g serve serve-s buildFind out more about deployment here: https://cra.link/deployment✔ Zipping artifacts completed.✔ Deploymentcomplete!https://staging.xxxxx.amplifyapp.com
Amplify Studioを使うことで、チームポータルのウェブページを簡単に実装することができました
筆者はFigmaもReactも初心者ですが、そこはAmplify Studioに導かれながら良しなにハードルを超えられたと思っています
ある程度FigmaやReactに関する理解があれば、1時間もかからず今回のようなサイトは作成できてしまうと思います
また、ローコード開発ツールのお手軽さを改めて体感でき、プロトタイプ開発時の選択肢として手札が増えたと思いました
引用をストックしました
引用するにはまずログインしてください
引用をストックできませんでした。再度お試しください
限定公開記事のため引用できません。