投稿時間:2023-07-18 07:10:07 RSSフィード2023-07-18 07:00 分まとめ(12件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
IT 気になる、記になる… YouTube、動画プレーヤーを長押しすると2倍速になる機能やプレビューサムネイルを大きく表示する機能をテスト中 https://taisy0.com/2023/07/18/174201.html premium 2023-07-17 21:56:03
IT 気になる、記になる… Amazonのオーディオブック配信サービス「Audible」の3ヶ月無料キャンペーンは本日まで https://taisy0.com/2023/07/18/174199.html audib 2023-07-17 21:44:21
AWS AWS Partner Network (APN) Blog Enhanced Ransomware Protection with Air-Gapped Veritas Alta Recovery Vault on AWS https://aws.amazon.com/blogs/apn/enhanced-ransomware-protection-with-air-gapped-veritas-alta-recovery-vault-on-aws/ Enhanced Ransomware Protection with Air Gapped Veritas Alta Recovery Vault on AWSBusiness and technology leaders are being challenged to improve security and resilience in the face of rising information security threats Alta Recovery Vault is a Veritas managed storage as a service offering for backups that helps reduce the risk of ransomware events Running on AWS Alta Recovery Vault enables customers to realize cloud storage benefits such as data immutability encryption in transit and at rest rapid recovery data durability and reduced total cost of ownership 2023-07-17 21:11:13
js JavaScriptタグが付けられた新着投稿 - Qiita npmライブラリを使うだけの開発者から、作れる側となるために第1歩 https://qiita.com/eno49conan/items/8226aef718c32c1f189c npminstallxxxxxjavascript 2023-07-18 06:17:16
AWS AWSタグが付けられた新着投稿 - Qiita Railsデプロイ時のエラー:error Command "webpack" not found. https://qiita.com/takuzo8679/items/f8f0c6b3772b13d991ba elasticbeanstalkrubyruby 2023-07-18 06:49:02
Ruby Railsタグが付けられた新着投稿 - Qiita Railsデプロイ時のエラー:error Command "webpack" not found. https://qiita.com/takuzo8679/items/f8f0c6b3772b13d991ba elasticbeanstalkrubyruby 2023-07-18 06:49:02
海外TECH DEV Community Secrets of Styling Forms (Using AWS Amplify Studio) https://dev.to/aws/secrets-of-styling-forms-using-aws-amplify-studio-49f0 Secrets of Styling Forms Using AWS Amplify Studio Forms are deceptively difficult When you create a form for your website you need to make a lot of decisions You have to worry about validation structure and how to send the data to your backend You need to figure out how to handle errors and how to style and configure your form You ll need to make sure your forms are accessible With this in mind AWS Amplify Studio with its form builder can help In this post I ll discuss how to add a new form using Amplify Studio that is connected to an AWS Appsync data source We ll look at how to customize that form by adding in a dark light mode We ll look at how we can further customize the validation rules and edit the error messages We ll then test our submissions by displaying the results using Amplify s JavaScript GraphQL API library If you d like to see the completed code Please check out this repo Getting StartedWe ll create a basic Todo form using Amplify studio To begin sign into your AWS Console and search for AWS Amplify and click on it If this is the first time using Amplify choose Get Started and click on the Get started again under Amplify Studio If you ve already created an Amplify app in this region you can click New app →Build an app Choose an app name click Confirm deployment Afterwords click Launch Studio to begin If you are an existing Amplify Studio user Launch Studio from your existing application This feature is available to all DataInside Amplify Studio let s create a data source that we can use with our form Click on Data in the menu Click Add model and create Todo Add the completed and the title fields After adding these models make sure you click the Save and Deploy button in the top right hand corner It may take a few minutes to deploy After the model is deployed you ll see a page with some instructions to pull the latest client config into your React application Make sure to copy the pull command Next js App SetupNow that we have our data and forms in place we can pull the information into our existing application I ll assume that you ve already created a new Next js application If not and you are starting a new Next js application make sure the App router turned off Open up your app and install these libraries with your favorite package manager npm install aws amplify ui react aws amplify react iconsIf not already installed make sure you also install the Amplify CLI globally npm install aws amplify cli gIf this is the first time using Amplify in a while make sure you upgrade to the latest version of the CLI amplify upgradeNext take the command you copied from the last section and paste it into your terminal running it in the root of your Next js project amplify pull appId lt replace this with your id gt envName lt replace with env name gt You should now see a few new files and directories in your project Since we are dealing with AppSync you ll need to generate some GraphQL query files amplify codegen addThis will generate some helpful GraphQL query subscription mutation files that we ll use later on in this tutorial Let s setup Amplify so we can use our new forms Note If you are using Next js with the app router or using Vite you may need some small additional configuration Please follow the Next js or Vite usage guide Adding Our Form and Customizing itLet s begin setting up our Next application so it can talk to our AppSync backend Inside your main entry point file in your application add these lines to configure Amplify with the correct styles import Amplify from aws amplify import awsExports from aws exports Amplify configure awsExports import aws amplify ui react styles css Next we ll be adding in a special theme file This file is used to customize global themes throughout your application In our case we will us to to override the default theme of our forms to support a dark mode The defaultDarkModeOverride will add this for us Create a new file called theme tsx in your src folder import Theme defaultDarkModeOverride from aws amplify ui react export const theme Theme name theme overrides defaultDarkModeOverride Next we ll add this Theme provider to a new Layout file In the src components folder create a new Layout tsx file Inside this file we ll add a new colorMode useState variable that we ll use to change the color of the theme The ThemeProvider surrounds our application and provides theming capabilities with design tokens to our app These tokens can completely override the look and feel of our application The official documentation discuss this in more detail import theme from theme import ColorMode ThemeProvider from aws amplify ui react import React from react export default function Layout children React PropsWithChildren const colorMode setColorMode React useState lt ColorMode gt light return lt ThemeProvider theme theme colorMode colorMode gt children lt ThemeProvider gt Let s add in a toggle button so users can select between dark and light mode We ll be using the react icons md set for these icons import theme from theme import MdOutlineDarkMode MdOutlineLightMode from react icons md import ColorMode Flex ThemeProvider ToggleButton ToggleButtonGroup from aws amplify ui react import React from react export default function Layout children React PropsWithChildren const colorMode setColorMode React useState lt ColorMode gt light return lt ThemeProvider theme theme colorMode colorMode gt lt Flex direction column gap width vw height vh backgroundColor background primary gt lt ToggleButtonGroup value colorMode size small isExclusive onChange value gt setColorMode value as ColorMode gt lt ToggleButton value light gt lt MdOutlineLightMode gt lt ToggleButton gt lt ToggleButton value dark gt lt MdOutlineDarkMode gt lt ToggleButton gt lt ToggleButtonGroup gt children lt Flex gt lt ThemeProvider gt The ToggleButtonGroup is from a set of UI primitives offered by the aws amplify ui react library It creates a nice looking toggle button On every click of the toggle button the colorMode is set and is updated in the ThemeProvider This will cause the screen to change between dark and light mode Finally we ll add in an AppHeader component to help sticky this layout to the top left hand corner We ll also add a nice icon using the Icon component primitive import theme from theme import MdOutlineDarkMode MdOutlineLightMode from react icons md import ColorMode Flex Icon ThemeProvider ToggleButton ToggleButtonGroup from aws amplify ui react import React from react function AppHeader children React PropsWithChildren return lt Flex as header direction row justifyContent space between alignItems center padding rem boxShadow small position sticky top left width backgroundColor background primary gt children lt Flex gt export default function Layout children React PropsWithChildren const colorMode setColorMode React useState lt ColorMode gt light return lt ThemeProvider theme theme colorMode colorMode gt lt Flex direction column gap width vw height vh backgroundColor background primary gt lt AppHeader gt lt Icon color brand primary fontSize xl paths d M C L C HC L C L Z d M C HC L C C C HC L C HC L C L Z gt lt ToggleButtonGroup value colorMode size small isExclusive onChange value gt setColorMode value as ColorMode gt lt ToggleButton value light gt lt MdOutlineLightMode gt lt ToggleButton gt lt ToggleButton value dark gt lt MdOutlineDarkMode gt lt ToggleButton gt lt ToggleButtonGroup gt lt AppHeader gt children lt Flex gt lt ThemeProvider gt We ll need to update the app tsx file so our new layout surrounds the application export default function App Component pageProps AppProps return lt Layout gt lt Component pageProps gt lt Layout gt Toggle the dark mode and see it in action Before After Adding our form and customizing themLet s now add in our form to the main route index tsx file in our Next js application Import the form onto the page import TodoForm from ui components TodoCreateForm export default function Home return lt TodoForm gt By convention this form is already connected to the AppSync model we created earlier Under the covers it uses something called DataStore to sync and send data to the backend We can customize this form to our liking Let s update the validation rule first Assume that we don t want users to enter in empty spaces We ll add a check for that and display a custom error message lt TodoForm padding onValidate title value validateResponse gt if value trim length return hasError true errorMessage Please enter a value return validateResponse gt With this validation in place users won t be able to submit a blank input in without getting an error The forms logic will handle the rest and will disable the input as well Imagine we want to show a message every time the user successfully submit a todo The generated forms have event handlers that you can hook into and listen for In this example we ll create a showSuccess variable that we can use to trigger an alert message that fades after two seconds const showSuccess setShowSuccess useState false lt TodoForm padding onValidate title value validateResponse gt if value trim length return hasError true errorMessage Please enter a value return validateResponse onSuccess gt setShowSuccess true setTimeout gt setShowSuccess false gt showSuccess amp amp lt Alert variation success gt Todo added lt Alert gt The onSuccess handler will trigger as soon as the form has submitted successfully We can then show an alert This Alert is another aws amplify ui react UI primitive Now that we have a way to add todo s we will need a way to show them Let s add a method that grabs all the todos This will use the Amplify JS library GraphQL API import API graphqlOperation from aws amplify import GraphQLQuery GraphQLSubscription from aws amplify api import ListTodosQuery Todo OnCreateTodoSubscription from API import listTodos from graphql queries const todos setTodo useState lt Todo gt const getTodos async gt const allTodos await API graphql lt GraphQLQuery lt ListTodosQuery gt gt query listTodos const filteredTodos allTodos data listTodos items filter todo gt todo deleted sort a b gt new Date a createdAt getTime new Date b createdAt getTime setTodo filteredTodos as Todo Since we created our application using Studio and form builder by convention our forms uses DataStore and conflict resolution turned on in the background Conflict resolution creates a versioned data source that enhances the object data model with metadata At this time you cannot turn this off when using Form Builder and studio What that means is that our Data model has a few extra meta fields including deleted and version These are automatically added to our data model when the model was created When you delete a record it doesn t get deleted the way you normally may expect Instead the deleted field gets set to true and the record remains Keep this in mind when dealing with data with conflict resolution turned on This is why we must filter out records with deleted set to true in our code that way we don t accidentally show deleted data It s good to know that if you decide to make updates or deletions to any record using the Amplify GraphQL API you must also include the version in the GraphQL input since conflict resolution is turned on The version field will increment on every change that occurs to the record You ll need to keep track of this version field when you make updates or delete an item To guarantee the correct order we sort by the createdAt time Now that we have a way to grab data we ll create a GraphQL subscription that will load as soon as the application loads using a useEffect import API graphqlOperation from aws amplify import GraphQLQuery GraphQLSubscription from aws amplify api import ListTodosQuery Todo OnCreateTodoSubscription from API import onCreateTodo from graphql subscriptions import useEffect useState from react const todos setTodo useState lt Todo gt useEffect gt getTodos const sub API graphql lt GraphQLSubscription lt OnCreateTodoSubscription gt gt graphqlOperation onCreateTodo subscribe next provider value gt setTodo prevValue gt prevValue value data onCreateTodo as Todo error error gt console warn error return gt sub unsubscribe We first trigger the getTodos and then run our subscription As soon as a new Todo is created the subscription is triggered We can then use our setTodo to save the data into the array Alternatively we could call getTodos again on every subscription change however for the sake of this post we ll manipulate the todos array and add the new todo to it instead Let s put this all together into one file I ve added a few more UI primitives to make things easier including a Collection component that is used with the array to display data in a nice row import Alert Card Collection Flex Heading Text useTheme from aws amplify ui react import TodoForm from ui components TodoCreateForm import API graphqlOperation from aws amplify import GraphQLQuery GraphQLSubscription from aws amplify api import ListTodosQuery Todo OnCreateTodoSubscription from API import listTodos from graphql queries import onCreateTodo from graphql subscriptions import useEffect useState from react export default function Home const showSuccess setShowSuccess useState false const todos setTodo useState lt Todo gt const getTodos async gt const allTodos await API graphql lt GraphQLQuery lt ListTodosQuery gt gt query listTodos const filteredTodos allTodos data listTodos items filter todo gt todo deleted sort a b gt new Date a createdAt getTime new Date b createdAt getTime setTodo filteredTodos as Todo useEffect gt getTodos const sub API graphql lt GraphQLSubscription lt OnCreateTodoSubscription gt gt graphqlOperation onCreateTodo subscribe next provider value gt setTodo prevValue gt prevValue value data onCreateTodo as Todo error error gt console warn error return gt sub unsubscribe const tokens useTheme return lt Flex direction row height width justifyContent stretch gap gt lt Flex direction column gap medium padding xxl backgroundColor background primary gt lt Text gt New ToDo lt Text gt lt TodoForm padding onValidate title value validateResponse gt if value trim length return hasError true errorMessage Please enter a value return validateResponse onSuccess gt setShowSuccess true setTimeout gt setShowSuccess false gt showSuccess amp amp lt Alert variation success gt Todo added lt Alert gt lt Flex gt lt Flex direction column flex padding xxl backgroundColor background secondary gt lt Heading level gt List of Todos lt Heading gt lt Collection gap small type list items todos gt todo gt lt Card variation elevated color tokens colors brand primary marginTop rem padding rem key todo id textDecoration todo completed line through gt todo title lt Card gt lt Collection gt lt Flex gt lt Flex gt Let s take a look at it in action And with dark mode after clicking the dark mode icon There is a lot more we could do here We could add a way to take already existing todos and delete them and mark them complete I ll leave that exercise for you DeletionOnce you re done with your application you can delete all your resources by running amplify delete ConclusionIn this blog post we ve learned about Amplify Studio forms how to customize them and how to add additional validation error messages If you d like to learn more about Amplify in general please check out the official docs You can also check the Amplify Studio tutorial for more information on how to use it Please let me know if you have any questions I m at ErikCH on Twitter 2023-07-17 21:37:19
Apple AppleInsider - Frontpage News Apple's App Store anti-steering rules put on hold as it appeals Supreme Court https://appleinsider.com/articles/23/07/17/apples-app-store-anti-steering-rules-put-on-hold-as-it-appeals-supreme-court?utm_medium=rss Apple x s App Store anti steering rules put on hold as it appeals Supreme CourtApple has been granted a motion to put on hold a decision forcing the company to change its anti steering rules within the App Store giving Apple a bit more time to move forward with an appeal Apple App StoreApple was granted the motion to put on hold the previous appeals court ruling on Monday With this mandate in place it gives Apple an additional days before it would need to make any changes related to anti steering rules within the App Store which all stems from the initial Epic Games vs Apple lawsuit Read more 2023-07-17 21:46:01
Apple AppleInsider - Frontpage News Select Apple Savings customers credited $100 after over-long withdrawal requests https://appleinsider.com/articles/23/07/17/select-apple-savings-customers-credited-100-after-over-long-withdrawal-requests?utm_medium=rss Select Apple Savings customers credited after over long withdrawal requestsApple Savings customers that inadvertently triggered fraud protection from large withdrawals had to wait days or weeks for money and now they are being credited for the inconvenience Apple SavingsIn June Apple Savings customers reported that some withdrawals were taking an unusual amount of time to process Some had to wait multiple weeks for their money to be transferred Read more 2023-07-17 21:31:31
ニュース BBC News - Home Corrie Mckeague: Mum's fury at bin safety years after airman death https://www.bbc.co.uk/news/uk-england-suffolk-66223747?at_medium=RSS&at_campaign=KARANGA airman 2023-07-17 21:08:40
ニュース BBC News - Home Heatwave: BBC correspondents on how people are coping https://www.bbc.co.uk/news/world-66226569?at_medium=RSS&at_campaign=KARANGA arizona 2023-07-17 21:46:21
ニュース BBC News - Home Willian: Brazilian winger rejoins Fulham on one-year deal https://www.bbc.co.uk/sport/football/66227650?at_medium=RSS&at_campaign=KARANGA london 2023-07-17 21:25:47

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)