投稿時間:2023-06-21 23:24:43 RSSフィード2023-06-21 23:00 分まとめ(28件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
IT ITmedia 総合記事一覧 [ITmedia ビジネスオンライン] ドコモ新プランに皮肉? MVNO日本通信「小さな注意書きで料金分かりにくい」 https://www.itmedia.co.jp/business/articles/2306/21/news196.html eximo 2023-06-21 22:32:00
TECH Techable(テッカブル) ChatGPT×LINEで簡単にES作成&添削!自己分析や企業分析にも役立つ就活ツール「内定くんAI」 https://techable.jp/archives/212013 chatgpt 2023-06-21 13:00:12
AWS AWS Japan Blog Amazon Rekognition Custom Labels でモデル精度を向上するための Tips https://aws.amazon.com/jp/blogs/news/tips-to-improve-your-amazon-rekognition-custom-labels-model/ amazonrekognitioncustomla 2023-06-21 13:46:27
python Pythonタグが付けられた新着投稿 - Qiita Python文法まとめ① https://qiita.com/otoriemuemu120/items/32b804e0af28aa6cc8fa macpytho 2023-06-21 22:42:26
js JavaScriptタグが付けられた新着投稿 - Qiita [ Rudex ] ReactとReduxでTODOアプリ制作! https://qiita.com/takenokoEngineer/items/e0a7a548a17b8d5b1810 react 2023-06-21 22:17:14
golang Goタグが付けられた新着投稿 - Qiita チーム開発参加の記録【2023-06~2023-08】(3) sqlc + jackc/pgx/v5(v5.4.1)からPostgreSQLの複合型の配列を使ってみた https://qiita.com/kanedaq/items/8b47443df2c42a15eaa9 goginsqlc 2023-06-21 22:14:53
Linux CentOSタグが付けられた新着投稿 - Qiita Azure VMでSSL対応のWebサーバを構築する② https://qiita.com/Negishi_tako/items/966dc36c992d1926df99 apache 2023-06-21 22:45:37
Azure Azureタグが付けられた新着投稿 - Qiita Vue.js(Vue3)でAzure OpenAI またはChatGPTのストリーム出力対応する https://qiita.com/natsu_san/items/5c586da111020b7bc6b2 VuejsVueでAzureOpenAIまたはChatGPTのストリーム出力対応する概要ChatGPTとかBingChatとかのタイピングぬるぬる出てくるのカッコいいので、自分でも実装してみたメモ。 2023-06-21 22:05:18
Git Gitタグが付けられた新着投稿 - Qiita 【Github】パスワードなしでgit pullしたい https://qiita.com/atm_33/items/248bc983dbb343068647 github 2023-06-21 22:13:37
Git Gitタグが付けられた新着投稿 - Qiita 【Git】Fork元のリポジトリのPRブランチをローカルでチェックアウトする方法 https://qiita.com/ryo_manba/items/382fe4f2d5a28dd1c4d7 feature 2023-06-21 22:00:30
海外TECH MakeUseOf How to Turn Off Telegram’s People Nearby Feature (and Why You Should) https://www.makeuseof.com/telegram-how-to-turn-off-people-nearby/ telegram 2023-06-21 13:45:18
海外TECH MakeUseOf How to Speed Up Your Amazon Fire TV Stick https://www.makeuseof.com/tag/speed-up-amazon-fire-tv-stick/ stick 2023-06-21 13:30:18
海外TECH DEV Community React useEffect: A complete guide with examples https://dev.to/alakkadshaw/react-useeffect-a-complete-guide-with-examples-3ebd React useEffect A complete guide with examplesReact useEffect is a powerful and essential hook that allows you to synchronize a component with external system Using the react useEffect in functional components you can do things like fetching data interacting with DOM elements and subscribing to event listeners Thus useEffect hook is an integral part of react developmentuseEffect setup dependencies oruseEffect gt some function dependencies array Dead Simple Chat allows you to easily add Chat to any React Application using powerful Javascript Chat API and SDK How to use useEffectCall the useEffect at the top of your component to declare an effectimport useState useEffect from react import createConnection from createConnection js function ChatRoom roomId const serverUrl setServerUrl useState https localhost useEffect gt const connection createConnection serverUrl roomId connection connect return gt connection disconnect serverUrl roomId the useEffect function accepts two arguments A function also called as setup that is the effect andAn Array An array containing dependenciessetup Setup is the function with your effects logic Your setup might additionally call an cleaner function When the component is first add to the DOM the react runs the setup function React runs the setup function will run on every re render only if one of the dependencies has changedWhen the setup function is run react will first run the clean up function with old dependencies if you provided the clean up function that is and then run the setup function with new valuesAfter the component is removed from the the DOM the react will run the clean up function for one last time Optional dependencies All the reactive values that are mentioned inside of the setup code Reactive values include props functions and all variables that are declared inside your component body The list of dependencies must be a constant number of items they should not change and they should be written in line in an array like dep dep dep Using the Object is notification the react compares each item with its previous value If you omit the dependencies array react will run the useEffect function after every re render of the component This can lead to unintended consequences and performance issues To make it so that the useEffect runs only once and if we don tuseEffect returns undefinedDead Simple Chat allows you to easily add Chat to any React Application using powerful Javascript Chat API and SDK Things to rememberuseEffect is a hook so you cannot call it inside loops or conditions You can only call the useEffect at the top of your componentIf you are not trying to synchronize with some external system like APIs database local storage etc then you don t need to use useEffectWhen strict mode is on React will run one more the setup clean up cycle If this causes a problem then you should implement a clean up functionEffects only run on the client side they don t run on the serverusually what happens is that the browser repaints the screen before process the state updates inside your effectIf you want to block the browser from repainting the screen you need replace useEffect with useLayoutEffectDead Simple Chat allows you to easily add Chat to any React Application using powerful Javascript Chat SDK Some Salient PointsConnecting to an external system The systems like API database or third party libraries are displayed on the page But these systems aren t controlled by react and hence are called externalIf you want to connect your component to an external system you can call useEffect at the top level of your component like soimport useEffect from react import createConnection from chat js function ChatRoom roomId const serverUrl setServerUrl useState https localhost useEffect gt const connection createConnection serverUrl roomId connection connect return gt connection disconnect serverUrl roomId this is how the system worksThe useEffect accepts two argumentsA setup function with setup code code that connects with the external resource that connects to the system a The setup function returns a clean up function with clean up code that disconnects from the systemA list of dependencies including every value that the component inside the functionsReact will call your setup and clean up functions multiple times whenever it is necessaryThese are the times your component might re renderWhen the first time your setup code runs and your component is added to the pageEvery time your dependencies have changed when your component re rendersFirst your clean up code runs with the old dependenciesthen your setup code runs with new props and stateyour clean up code runs a final time when your component is removed from the pageLet us see what is happening with our example aboveWhen the chat Room component gets added to the pafge it will connect to the chat room with initial serverURl and roomIdIf either the serverUrl or the roomId Changes because of the re render cause the user got to another chat room or the system connected the user to another server then the useEffect with disconnect from the previous server or room and connect to the new roomWhen the chat room component is removed from the page the useEffect will disconnect the server and the chat room one last timeTo help you debug your application react will run the setup and cleanup functions again before the setupIf this causes visiable issues there is something wrong with your clean up function The clean up function should stop or undo whatever the setup was doingThe rule of thumb is that the user should not be able to distinguish between the development where the setup clean up and setup is happening and in production where set up and clean up happensNote External system means any peice of code that is not controlled by react this could includeA timer that is controlled with setInterval setTimeout clearInterval etcAn event subscription using window eventListener and window removeEventListener third party animation library with an API like animation start and animation reset Dead Simple Chat allows you to easily add Chat to any React Application using powerful Javascript Chat API and SDK Example Connecting to a chat serverIn this example the ChatRoom component uses an Effect to stay connected to the external system It uses roomId as an prop to identify a chat room ServerUrl is the state variable Chat Room component has the useEffect hook to create a connection when the roomId or the serverURL changeswhen the component is unmounted it disconnects from the server Lastly the component renders an input field for the server URL and a welcome message App js import useState useEffect from react import createConnection from chat js function ChatRoom roomId const serverUrl setServerUrl useState https localhost useEffect gt const connection createConnection serverUrl roomId connection connect return gt connection disconnect roomId serverUrl return lt gt lt label gt Server URL lt input value serverUrl onChange e gt setServerUrl e target value gt lt label gt lt h gt This is the roomId room lt h gt lt gt export default function App const roomId setRoomId useState general const show setShow useState false return lt gt lt label gt Choose the chat room lt select value roomId onChange e gt setRoomId e target value gt lt option value cool gt cool lt option gt lt option value awesome gt awesome lt option gt lt option value movies gt movies lt option gt lt select gt lt label gt lt button onClick gt setShow show gt show Close chat Open chat lt button gt show amp amp lt hr gt show amp amp lt ChatRoom roomId roomId gt lt gt export function createConnection serverUrl roomId A real implementation would actually connect to the server return connect console log Connecting to roomId room at serverUrl disconnect console log Disconnected from roomId room at serverUrl Dead Simple Chat allows you to easily add Chat to any React Application using powerful Javascript Chat API and SDK Example Using useEffect to track browsers pointer movementIn this example the external event is the browsers DOM Normally you can have event listeners with the JSX but you cannot listen to the global window object like thisAn effect lets you connect to the window object and listen to the eventsimport useState useEffect from react export default function App const position setPosition useState x y useEffect gt function handleMove e setPosition x e clientX y e clientY window addEventListener pointermove handleMove return gt window removeEventListener pointermove handleMove return lt div style position absolute backgroundColor pink borderRadius opacity transform translate position x px position y px pointerEvents none left top width height gt We are importing the useState and useEffect hooks these hooks lets us maintain state and take care of external effects in our componentThe useEffect hook has a handleMove event listener function It takes e as an argument and sets the position of clientx and clienty properties of the event objectwhich is the X and Y co ordinates of the mouse pointer The useEffect hook adds an event listener function called the handleMove to the window Object that listens to the pointermove eventsDead Simple Chat allows you to easily add Chat to any React Application using powerful Javascript Chat API SDK We also have a clean up funtion that removes the event listener when the component is unmountedLastly we have a div element with a pink semi transparent background that tracks where the pointer is movingThe element also has pointerEvents none to avoid having the pointer interact with other element on the page ConclusionIn this article we have explained how to use useEffect to connect to an external source and What we mean by external source External source is something that is not controlled by the react like an API or a Database etc We also gave a few examples and explained what is the role of the clean up function and how the dependencies are required to be added in an array format to the setupThanks for reading the articleNote This article was originally written on the DeadSimpleChat website React useEffect A complete guide with examples 2023-06-21 13:36:47
海外TECH DEV Community Configuring Terraform backend with AWS S3 and DynamoDB state locking https://dev.to/bhusein/configuring-terraform-backend-with-aws-s3-and-dynamodb-state-locking-96l Configuring Terraform backend with AWS S and DynamoDB state lockingIn this blog post I have explained how to create a remote Terraform backend using Amazon S and DynamoDB services with state locking Prerequisites are installed and configured AWS CLI and Terraform with some code editor like VS Code For better understanding of importance to create Terraform backend with S first it s necessary to understand what is state file backend and what type of backend is a standard S backend besides that what is state file lock and what purpose does it have within a teamwork which we will see later in the demo part The Terraform state file represents a crucial part of Terraform infrastructure that contains information about managed infrastructure and its configuration When we initially create our infrastructure the state file is saved locally by default as a terraform tfstate file in JSON format Besides local backend we also have standard backend which essentially is a remote backend on AWS S service or some other cloud provider and it s always defined inside of Terraform backend configuration code block which we will write later Why is the standard backend like AWS S so important It s important because of team collaboration security reasons etc but again it s not a complete solution because when two or more team members work on infrastructure simultaneously they could have certain issues with resource modification or creation because of unpredictable situations like executing other processes before the state file has been finalized I will include more illustrative information about this issue later in the post To avoid this issue Terraform can lock our state State file locking to prevent other team members from overwriting our infrastructure by using the same but modified state file simultaneously In other words changes that other team members make will be applied in certain order which we will see later with Acquiring state lock and Releasing state lock prompts while working on our infrastructure In this case state file is locked which provides us with protection of our state file from potential changes that could be made by other team members at the same time In AWS we can use locking feature via DynamoDB table which we will see in action later Terraform backend infrastructure diagram in AWSThe practical part of this blog post has components First we will create simple infrastructure using the EC Terraform Instance module After that we will create a backend with Terraform backend code block which will build S bucket in our AWS account and save the state file here In the third part we will write code for DynamoDB state locking via Terraform and see how it looks in our AWS account DEMO creating infrastructure using EC Terraform instance module Before we start we should validate if AWS CLI amp Terraform are installed by using following commands aws version terraform versionIn the previous introduction part I added links that point toward official documentation that we can use to install and configure both AWS CLI and Terraform After we confirmed that we have these two tools installed we can start creating our basic infrastructure First we will create config tf file in VS Code and write the following code terraform required providers aws source hashicorp aws version provider aws region eu central After that we will create variables tf file where we will write the following variables variable stage name description The stage name for the environment type string default production variable instance name description Instance name type string default web server variable instance type description EC instance type type string default t micro variable key name description The name of the SSH key pair type string default ec key variable subnet id description Subnet ID type string default subnet xxxxxxxxx write your subnet ID After that we will create main tf file where we will write code for our infrastructure resources we will also create two resources for demo purposes AWS EC instance as a web server with one security group module ec instance source terraform aws modules ec instance aws name instance var instance name instance type var instance type key name var key name monitoring true vpc security group ids aws security group web server sg id subnet id var subnet id tags Name var instance name Stage var stage name ManagedBy Terraform resource aws security group web server sg name web server sg description Security group for our web server ingress from port to port protocol tcp cidr blocks ingress from port to port protocol tcp cidr blocks egress from port to port protocol cidr blocks The next step is to run the following commands in our terminal terraform init where we can see local backend initializing terraform plan where we can see the infrastructure plan terraform apply where we build the planned infrastructure we should use yes value when prompted to execute the command and create resources After the command has been executed besides our tf files Terraform has created terraform tfstate file and if we execute cat terraform tfstate we can see the content of our terraform tfstate file This screenshot contains only part of the file where we can see JSON code that provides us with version of terraform tfstate file including many other information like terraform version that was used to generate this file and very important part that contains resources with attributes like arn type name and other specific resource values After the terraform tfstate file has been generated we are ready to start with the practical part for our backend creation DEMO Creating Terraform backend with AWS S service When we built our infrastructure Terraform has created a state file that is saved locally on our machine In official documentation we can see code which we can write to build our S bucket on AWS using Terraform and then we will migrate our state file to that bucket Before we proceed with practical part I think it s very important to add few paraphrased notes related to state file from the book Terraform Up and Running rd Edition If we use Terraform for our personal projects it s OK to use terraform tfstate file locally on our machine but if we want to use Terraform within our team on the real project we can encounter several issues with the approach above our team members will not be able to access state file because our local machine is not a shared location there would be no locking option and we could not isolate state files We can save our Terraform code on VCS ie Github but we should not save our state file in the same way Why Because of the fact that code inside our Terraform state file is saved in textual format and can contain confidential information For example if we are using aws db instance resource to create our database Terraform will save database username and password in state file which will be in textual format and it will upload it on GitHub which can represent security risk later Instead of using VCS for remote backend the best practice is to use Terraform code block for remote backend in this case we will use this code block later for creating Amazon S bucket Remote backend will provide us with a locking feature that is useful when several team members are working on a project and running the terraform apply command In that case the first team member will have a lock on their side and will be able to apply the changes while other team members will be prompted to wait for a lock to be released This does not mean that they will not be able to work it only means that their changes will be applied in some order Besides this we should mention encryption in transit and how much of benefits we have when we are using Terraform with AWS S service which is Amazon s managed file store and in the book above it s mentioned as the recommended way for remote backend You can read more about this in chapter How to Manage Terraform State Now we should continue with our practical part first we will create a backend tf file which we will use to write our code related to bucket and key parameters We should also add region parameters but we already included them previously in our code resource aws s bucket terraform backend bucket bucket backend bucket iac terraform tags Name tf bucket Environment dev When it comes to naming convention we can name our S bucket like backend bucket iac terraform and you should provide it with some unique name According to the Terraform Up and Running rd Edition it s recommended to add few layers of protection for our S bucket that will enable S versioning the default encryption and block all public access to S bucket resource aws kms key mykey description This key is used to encrypt bucket objects deletion window in days resource aws s bucket server side encryption configuration default bucket aws s bucket terraform backend bucket id rule apply server side encryption by default kms master key id aws kms key mykey arn sse algorithm aws kms resource aws s bucket versioning versioning bucket enabled bucket aws s bucket terraform backend bucket id versioning configuration status Enabled resource aws s bucket public access block public access bucket aws s bucket aws s bucket terraform backend bucket id block public acls true block public policy true ignore public acls true restrict public buckets true After we wrote our code in the backend tf file we should run the terraform plan command to see what will be built from our infrastructure in the output we should see that Terraform will create an S bucket with default encryption and enabled versioning After that we will apply the terraform apply command to apply all changes We can see that the command has been executed successfully and we can confirm in our AWS S service dashboard that S bucket has been created However our S bucket is empty and now it s time to write terraform backend configuration code block in our backend tf file with values that we used when we were creating the S bucket terraform backend s bucket backend bucket iac terraform key terraform tfstate region eu central After we wrote this code block to store our state file in S bucket we have to run the terraform init command to initialize our terraform project again We will get a prompt this time with a question if we want to copy our state to the new “S backend we should write the yes value After the command is executed successfully when we open our S bucket we can confirm that the terraform state file is placed here At the same time if we open our terraform tfstate locally on our machine we will see that the file is empty At this moment we have successfully built our Terraform backend where instead of using our terraform tfstate file that we have locally we are using terraform tfstate file remotely from our S bucket and now it s time to initialize DynamoDB state locking DEMO DynamoDB state lockingAfter we created our S bucket and migrated our state file we should create DynamoDB state locking by creating a table for Terraform state locking with a simple hash LockID key and one string attribute We can write code for this in our backend tf file resource aws dynamodb table terraform locks name terraform state locking billing mode PAY PER REQUEST hash key LockID attribute name LockID type S After that we will run terraform apply command for Terraform to create our table within the DynamoDB service and we will get the following output on the screenshot below Now we will update our backend code block within our backend tf file with the name of the recently created database terraform backend s bucket backend bucket iac terraform key terraform tfstate region eu central dynamodb table terraform state locking encrypt true After that we will run terraform init reconfigure to reconfigure our state locking In the screenshot below we can see our table inside of DynamoDB service With this backend configuration Terraform will automatically pull the latest changes on the state file from S bucket and later by running the terraform apply command it will update and set the latest state file changes on the S bucket We can test this by using output variables that we will write in our variables tf file output s bucket arn value aws s bucket terraform backend bucket arndescription The ARN of the S bucket output dynamodb table name value aws dynamodb table terraform locks namedescription The name of the DynamoDB table These variables will print out the Amazon Resource Name arn of our S bucket and the name of our DynamoDB table After we run the terraform apply command we can notice Acquiring state lock in the beginning and Releasing state lock at the end prompts We can also see that we had an entry inside of our DynamoDB table with a corresponding Digest value Digest value is a hash value of our terraform tfstate file besides integrity check if the content of our file has been changed or modified Digest hash code will also change which tells us that new change has been made We can test that if we comment out some existing resource inside of our code change modify or add a new one and then run the terraform apply command In the screenshot below we can see Info that is providing information about state infrastructure When changes have been applied successfully we can see a new Digest hash value Conclusion The goal of this blog post was to explain a way to create a remote Terraform backend by using S and DynamoDB with state locking For better understanding of how important it is to create Terraform backend with S I explained what is a state file backend and what type of backend is a standard S backend what is a state file lock and what kind of purpose does it have when it comes to teamwork and collaboration Besides theory in the practical part I explained how to create infrastructure by using the code from the Terraform Up and Running book and official documentation I tried to provide some simple and practical insights and keep the state file topic in the scope of the article without addressing some other important concepts such as state file isolation and how to practically apply terraform remote state which probably will be explained in some of my future posts To avoid unnecessary costs we can clean our resources by using the terraform destroy command just remember to avoid using this command within the production environment Literature Official documentation 2023-06-21 13:16:58
海外TECH DEV Community CSS in Micro Frontends https://dev.to/florianrappl/css-in-micro-frontends-4jai CSS in Micro FrontendsCover by Shubham s Web on Unsplash One of the questions I get asked the most is how to deal with CSS in micro frontends After all styling is always something that is needed for any UI fragment however it is also something that is globally shared and therefore a potential source of conflict In this article I want to go over the different strategies that exist to tame CSS and make it scale for developing micro frontends If anything in here sounds reasonable to you then consider also looking into The Art of Micro Frontends The code for the article can be found at github com piral samples css in mf Make sure to check out the sample implementations Does the handling of CSS impact every micro frontend solution Let s check the available types to validate this Types of Micro FrontendsIn the past I ve written a lot about what types of micro frontends exist why they exist and when what type of micro frontend architecture should be used Going for the web approach implies using iframes for using UI fragments from different micro frontends In this case there are no constraints as every fragment is fully isolated anyway In any other case independent of your solution uses client or server side composition or something in between you ll end up with styles that are evaluated in the browser Therefore in all other cases you ll care about CSS Let s see what options exist here No Special TreatmentWell the first and maybe most or depending on the point of view least obvious solution is to not have any special treatment Instead each micro frontend can come with additional stylesheets that are then attached when the components from the micro frontend are rendered Ideally each component only loads the required styles upon first rendering however since any of these styles might conflict with existing styles we can also pretend that all problematic styles are loaded when any component of a micro frontend renders The problem with this approach is that when generic selectors such as div or div a are given we ll restyle also other elements not just the fragments of the originating micro frontend Even worse classes and attributes are no failsafe guard either A class like foobar might also be used in another micro frontend You ll find the example for two conflicting micro frontends in the referenced demo repository at solutions default A good way out of this misery is to isolate the components much more like web components Shadow DOMIn a custom element we can open a shadow root to attach elements to a dedicated mini document which is actually shielded from its parent document Overall this sounds like a great idea but like all the other solutions presented here there is no hard requirement Ideally a micro frontend is free to decide how to implement the components Therefore the actual shadow DOM integration has to be done by the micro frontend There are some downsides of using the shadow DOM Most importantly while the styles inside the shadow DOM stay inside global styles are also not impacting the shadow DOM This seems like an advantage at first however since the main goal of this whole article is to only isolate the styles of a micro frontend you might miss out requirements such as applying some global design system e g Bootstrap To use the shadow DOM for styling we can either put the styles in the shadow DOM via a link reference or a style tag Since the shadow DOM is unstyled and no styles from the outside propagate into it we ll actually need that Besides writing some inline style we can also use the bundler to treat css or maybe something like shadow css as raw text This way we ll get just some text For esbuild we can configure the pre made configuration of piral cli esbuild as follows module exports function options options loader css text options plugins splice return options This removes the initial CSS processor SASS and configures a standard loader for css files Now having something in the shadow DOM styled works like import css from style css customElements define name class extends HTMLElement constructor super this attachShadow mode open connectedCallback this style display contents const style this shadowRoot appendChild document createElement style style textContent css The code above is a valid custom element that will be transparent from the styling perspective display contents i e only its contents will be reflected in the render tree It hosts a shadow DOM that contains a single style element The content of the style is set to the text of the style css file You ll find the example for two conflicting micro frontends in the referenced demo repository at solutions shadow dom Another reason for avoiding shadow DOM for domain components is that not every UI framework is capable of handling elements within the shadow DOM Therefore an alternative solution has to be looked for anyway One way is to fall back to using some CSS conventions instead Using a Naming ConventionIf every micro frontend follows a global CSS convention then conflicts can be avoided on the meta level already The easiest convention is to prefix each class with the name of the micro frontend So for instance if one micro frontend is called shopping and another one is called checkout then both would rename their active class to shopping active checkout active respectively The same can be applied to other potentially conflicting names too As an example instead of having an ID like primary button we d call it shopping primary button in case of a micro frontend called shopping If for some reason we need to style an element we d should use descendent selectors such as shopping img to style the img tag This now applies to img elements within some element having the shopping class The problem with this approach is that the shopping micro frontend might also use elements from other micro frontends What if we would see div shopping gt div checkout img Even though img is now hosted integrated by the component brought through the checkout micro frontend it would be styled by the shopping micro frontend CSS This is not ideal You ll find the example for two conflicting micro frontends in the referenced demo repository at Even though naming conventions solve the problem up to some degree they are still prone to errors and cumbersome to use What if we rename the micro frontend What if the micro frontend gets a different name in different applications What if we forget to apply the naming convention at some points This is where tooling helps us CSS ModulesOne of the easiest ways to automatically introduce some prefixes and avoid naming conflicts is to use CSS modules Depending on your choice of bundler this is either possible out of the box or via some config change Import default export from CSSimport styles from style modules css Apply lt div className styles active gt Active lt div gt The imported module is a generated module holding values mapping their original class names e g active to a generated one The generated class name is usually a hash of the CSS rule content mixed with the original class name This way the name should be as unique as possible As an example let s consider a micro frontend constructed with esbuild For esbuild you d need a plugin esbuild css modules plugin and respective config change to include CSS modules Using Piral we only need to adjust the config already brought by piral cli esbuild We remove the standard CSS handling using SASS and replace it by the plugin const cssModulesPlugin require esbuild css modules plugin module exports function options options plugins splice cssModulesPlugin return options Now we can use CSS modules in our code as shown above You ll find the example for two conflicting micro frontends in the referenced demo repository at solutions css modules There are a couple of disadvantages that come with CSS modules First it comes with a couple of syntax extensions to standard CSS This is necessary to distinguish between styles that we want to import and therefore pre process hash and styles that should remain as is i e to be consumed later on without any import Another way is to bring the CSS directly in the JS files CSS in JSCSS in JS has quite a bad reputation lately however I think this is a bit of misconception I also prefer to call it CSS in Components because it brings the styling to the components itself Some frameworks Astro Svelte even allow this directly via some other way The often cited disadvantage is performance which is usually reasoned by composing the CSS in the browser This however is not always necessary and in the best case the CSS in JS library is actually build time driven i e without any performance drawback Nevertheless when we talk about CSS in JS or CSS in Components for that matter we need to consider the various options which are out there For simplicity I ve only included three Emotion Styled Components and Vanilla Extract Let s see how they can help us to avoid conflicts when bringing together micro frontends in one application EmotionEmotion is very cool library that comes with helpers for frameworks such as React but without setting these frameworks as a prerequisite Emotion can be very nicely optimized and pre computed and allows us to use the full arsenal of available CSS techniques Using pure Emotion is rather easy first install the package npm i emotion cssNow you can use it in the code as follows import css from emotion css const tile css background blue color yellow flex display flex justify content center align items center later lt div className tile gt Hello from Blue lt div gt The css helper allows us to write CSS that is parsed and placed in a stylesheet The returned value is the name of the generated class If we want to work with React in particular we can also use the jsx factory from Emotion introducing a new standard prop called css or the styled helper npm i emotion react emotion styledThis now feels a lot like styling is part of React itself For instance the styled helper allows us to define new components const Output styled output border px dashed red padding rem font weight bold later lt Output gt I am groot from red lt Output gt In contrast the css helper prop gives us the ability to shorten the notation a bit lt div css background red color white flex display flex justify content center align items center gt Hello from Red lt div gt All in all this generates class names which will not conflict and provide the robustness of avoiding a mixup of styles The styled helper in particular was inspired heavily from the popular styled components library You ll find the example for two conflicting micro frontends in the referenced demo repository at solutions emotion Styled ComponentsThe styled components library is arguably the most popular CSS in JS solution and quite often the reason for the bad reputation of such solutions Historically it was really all about composing the CSS in the browser but in the last couple of years they really brought that forward immensely Today you can have some very nice server side composition of the used styles too In contrast to emotion the installation for React requires a few less packages The only downside is that typings are an afterthought so you need to install two packages for full TypeScript love npm i styled components savenpm i types styled components save devOnce installed the library is already fully usable import styled from styled components const Tile styled div background blue color yellow flex display flex justify content center align items center later lt Tile gt Hello from Blue lt Tile gt The principle is the same as for emotion So let s explore another option that tries to come up with zero cost from the beginning not as an afterthought You ll find the example for two conflicting micro frontends in the referenced demo repository at solutions styled components Vanilla ExtractWhat I wrote beforehand about utilizing types to be closer to the components and avoiding unnecessary runtime costs is exactly what is covered by the latest generation of CSS in JS libraries One of the most promising libraries is vanilla extract css There are two major ways to use the library Integrated with your bundler frameworkDirectly with the CLIIn this example we choose the former with its integration to esbuild For the integration to work we need to use the vanilla extract esbuild plugin package Now we integrate it in the build process Using the piral cli esbuild configuration we only need to add it to the plugins of the configuration const vanillaExtractPlugin require vanilla extract esbuild plugin module exports function options options plugins push vanillaExtractPlugin return options For Vanilla Extract to work correctly we need to write css ts files instead of the plain css or sass files Such a file could look as follows import style from vanilla extract css export const heading style color blue This is all valid TypeScript What we ll get in the end is an export of a class name just like we got from CSS modules Emotion you get the point So in the end the style above would be applied like this import heading from Page css ts later lt h className heading gt Blue Title should be blue lt h gt This will be fully processed at build time not runtime cost whatsoever You ll find the example for two conflicting micro frontends in the referenced demo repository at solutions vanilla extract Another method that you might find interesting is to use a CSS utility library such as Tailwind CSS Utilities like TailwindThis is a category on its own but I thought since Tailwind is the dominant tool in this one I ll only present Tailwind The dominance of Tailwind even goes so far that some people are asking questions like do you write CSS or Tailwind This is quite similar to the dominance of jQuery in the DOM manipulation sector ca where people asked is this JavaScript or jQuery Anyhow using a CSS utility library has the advantage that styles are generated based on usage These styles will not conflict as they are always defined in the same way by the utility library So each micro frontend will just come with the portion of the utility library that is necessary to display the micro frontend as desired In case of Tailwind and esbuild we ll also need to install the following packages npm i autoprefixer tailwindcss esbuild style pluginThe configuration of esbuild is a bit more complicated than beforehand The esbuild style plugin is essentially a PostCSS plugin for esbuild so it must be configured correctly const postCssPlugin require esbuild style plugin module exports function options const postCss postCssPlugin postcss plugins require tailwindcss require autoprefixer options plugins splice postCss return options Here we remove the default CSS handling plugin SASS and replace it by the PostCSS plugin using both the autoprefixer and the tailwindcss extensions for PostCSS Now we need to add a valid tailwind config js file module exports content src tsx theme extend plugins This is essentially the bare minimum for configuring Tailwind It just mentions that the tsx files should be scanned for usage of Tailwind utility classes The found classes will then be put into the CSS file The CSS file therefore also needs to know where the generated used declarations should be contained As bare minimum we ll have only the following CSS tailwind utilities There are other tailwind instructions too For instance Tailwind comes with a reset and a base layer However in micro frontends we are usually not concerned with the these layers This falls into the concern of an app shell or orchestrating application not in a domain application The CSS is then replaced by classes that are already specified from Tailwind lt div className bg red text white flex flex justify center items center gt Hello from Red lt div gt You ll find the example for two conflicting micro frontends in the referenced demo repository at solutions tailwind ComparisonAlmost every method presented so far is a viable contender for your micro frontend In general these solutions can also be mixed One micro frontend could go for a shadow DOM approach while another micro frontend is happy with Emotion A third library might opt in for Vanilla Extract In the end the only thing that matters is that the chosen solution is collision free and does not come with a huge runtime cost While some methods are more efficient than others they all provide the desired styling isolation MethodMigration EffortReadabilityRobustnessPerformance ImpactConventionMediumHighLowNoneCSS ModulesLowHighMediumNone to LowShadow DOMLow to MediumHighHighLowCSS in JSHighMedium to HighHighNone to HighTailwindHighMediumHighNoneThe performance impact depends largely on the implementation For instance for CSS in JS you might get a high impact if parsing and composition if full done at runtime If the styles are already pre parsed but only composed at runtime you might have a low impact In case of a solution like Vanilla Extract you would have essentially no impact at all For shadow DOM the main performance impact could be the projection or move of elements inside the shadow DOM which is essentially zero combined with the re evaluation of a style tag This is however quite low and might even yield some performance benefits of the given styles are always to the point and dedicated only for a certain component to be shown in the shadow DOM In the example we had the following bundle sizes MethodIndex kB Page kB Sheets kB Overall kB Size Default Convention CSS Modules Shadow DOM Emotion Styled Components Vanilla Extract Tailwind Take these numbers with a grain of salt because in case of Emotion and Styled Components the runtimes could and presumably even should be shared Also the given example micro frontends have really been small overall size being kB for all the UI fragments For a much larger micro frontend the growth would certainly not be as problematic as sketched here The size increase of the shadow DOM solution can be explained by the simple utility script we provided for easily wrapping existing React renderings into the shadow DOM without spawning a new tree If such a utility is centrally shared then the size would be much closer to the other more lightweight solutions ConclusionDealing with CSS in a micro frontend solution does not need to be difficult it just needs to be done in a structured and ordered way from the beginning otherwise conflicts and problems will arise In general choosing solutions such as CSS modules Tailwind or a scalable CSS in JS implementation are advisable 2023-06-21 13:12:17
Apple AppleInsider - Frontpage News Apple's iPad 9th Generation drops to $249.99 in early Amazon Prime Day sale https://appleinsider.com/articles/23/06/21/apples-ipad-9th-generation-drops-to-24999-in-early-amazon-prime-day-sale?utm_medium=rss Apple x s iPad th Generation drops to in early Amazon Prime Day saleAmazon has issued a special deal on the iPad th Generation ahead of Prime Day with bonus savings at checkout dropping the price to Save on Apple s iPad Mere hours after officially announcing Prime Day dates Amazon is slashing prices on Apple products with the iPad th Generation dipping to thanks to a instant rebate stacked with in bonus savings at checkout The GB Wi Fi model is available at the discounted price in your choice of Silver or Space Gray Read more 2023-06-21 13:58:18
Apple AppleInsider - Frontpage News Xcode's power keeps Mac relevant for Apple, despite iPhone dominance https://appleinsider.com/articles/23/06/21/xcodes-power-keeps-mac-relevant-for-apple-despite-iphone-dominance?utm_medium=rss Xcode x s power keeps Mac relevant for Apple despite iPhone dominanceThe Mac continues to enjoy strong consumer demand and serves a crucial purpose in supporting the functionality of the iPhone and the upcoming Vision Pro headset Consumer demand for Mac remains strongAt the recent WWDC keynote Apple unveiled the Vision Pro mixed reality headset and updates to the Mac lineup New machines include an upgraded Mac Studio Apple Silicon Mac Pro and a inch MacBook Air Read more 2023-06-21 13:48:25
Apple AppleInsider - Frontpage News Apple still has a lot of secret apps for Vision Pro in the works https://appleinsider.com/articles/23/06/21/apple-still-has-a-lot-of-secret-apps-for-vision-pro-in-the-works?utm_medium=rss Apple still has a lot of secret apps for Vision Pro in the worksA new report claims that Apple Vision Pro was meant to be demoed with fitness apps games and even running Mac apps directly but Apple only showed what little is working now Tim Cook announces One More Thing ーthe Apple Vision ProWhen Apple unveiled its long awaited Vision Pro headset it did so with demonstrations of many apps and tools ーbut not the ones that were expected Prior to launch there were reports of gaming and fitness apps for the headset and ones to do with health and wellness Read more 2023-06-21 13:43:05
Apple AppleInsider - Frontpage News Daily deals: $200 off M2 MacBook Pro, $329 Apple Watch Series 8, 72% off JBL Bluetooth speaker, more https://appleinsider.com/articles/23/06/21/daily-deals-200-off-m2-macbook-pro-329-apple-watch-series-8-72-off-jbl-bluetooth-speaker-more?utm_medium=rss Daily deals off M MacBook Pro Apple Watch Series off JBL Bluetooth speaker moreToday s most valuable deals include an Onson in robot vacuum for off an M Mac mini AppleCare kit off a pack of Pelican AirTag holders and off a Samsung Galaxy Ultra S leather cover Save on an M MacBook ProThe AppleInsider team searches the web for unbeatable deals at e commerce stores to curate a list of stellar discounts on popular tech gadgets including discounts on Apple products TVs accessories and other items We share our top finds daily to help you save money Read more 2023-06-21 13:08:34
海外TECH Engadget Nest WiFi Pro review: Google’s WiFi 6E mesh is more approachable than the rest https://www.engadget.com/nest-wifi-pro-review-googles-wifi-6e-mesh-is-more-approachable-than-the-rest-130029818.html?src=rss Nest WiFi Pro review Google s WiFi E mesh is more approachable than the restGoogle s pitch for its own mesh networking products has been to focus on clever trade offs to keep the cost down making it accessible to the masses The Nest WiFi Pro the company s latest flagship builds upon that existing and winning formula with the addition of WiFi E Part of its appeal is the Google brand plus the promise of regular free software updates and tight integrations with most of the world s smart home players In a head to head race the Nest WiFi Pro will be bested by plenty of its competitors but Google s user friendliness means it s the default option for pretty much everyone HardwareAs I said in our main mesh WiFi buyer s guide I ve been using Google s first generation version for years and also reviewed the second generation Nest WiFi so I feel like this is my turf The Nest WiFi Pro is Google s first to harness WiFi E which was irritatingly omitted from the last model on cost grounds Because of this they can t integrate with your existing Google Nest WiFi hardware meaning that any upgrade will require you to start fresh In terms of looks the Pros are ovoid bumps that stand taller than their predecessors and demand more space Round back you ll find the jack for the barrel power cable and two ethernet ports which Google says “support Gbps wired speeds per router Inside it packs a Cortex A dual core bit ARM CPU paired with GB of RAM and GB of storage like its predecessor It is available in four colors Snow Linen Fog and Lemongrass The Nest WiFi Pro doesn t reserve a chunk of its spectrum for dedicated backhaul Instead it dynamically shunts traffic around the available space for optimal performance which will primarily take place on the GHz band since plenty of devices in our homes don t have the components necessary to access it Google adds that using GHz as backhaul frees up lots of space in the and GHz bands improving performance for all the other devices on the network One interesting tweak from the last model is that you can t get the Pro with a built in smart speaker This is good since I never liked the idea of having a speaker inside my WiFi apparatus But I will concede that I did like being able to use Spotify Connect on the original Nest WiFi in my kitchen without buying another speaker InstallationSince it s a Google product expect the Nest WiFi Pro to be relatively easy to install through your phone ーfor most of the process If you like me in this instance already had a Google mesh in place you ll need to factory reset wipe and deactivate everything Once done you can just connect the first node to your modem with an ethernet cable supplied and let the app do the rest for you The Google Home app will almost instantly find the new product waiting to be installed and get you started It took me ten minutes to get the first one running and that included an unrelated issue with my cable modem that forced me to restart It took another ten minutes to install the other nodes but all I had to do was scan the QR code and follow the on screen instructions The app doesn t offer any advice about optimum node placement or identifying potential weak spots Google s website offers the stock line that you should put a node halfway between the primary and wherever in your home you need WiFi That s fine but I suspect novice users might appreciate more guidance especially if they re struggling with structural issues that mean adjoining rooms aren t getting a good signal PerformancePhoto by Daniel Cooper EngadgetI don t have many WiFi E compatible devices at home and there was a fair distance between the nearest node and my office so I didn t have high hopes that switching to the new system would deliver great gains Yet compared to the WiFi module in my office which is connected via Ethernet to my modem I saw my speed jump from around Mbps to an average of Mbps The only place where the Nest WiFi Pro s connection was anything other than eye wateringly fast was in my notorious back bedroom The room surrounded by Victorian and modern plumbing was previously barren territory for my older system but it was now joined up here And while speeds fell to Mbps I never saw a dropout or stutter in performance In fact WiFi performance in that room is more than sufficient to work and take video calls Despite the fewer modules connectivity was stable and I never noticed a drop when I ran between rooms Armed with all the devices I could muster me and my kids scuttled around the house walking to the furthest points of the house watching plenty of streamed video and none reported an issue My average speed tests shook down to close to Mbps and the connection was smooth enough for my purposes Additional featuresThe Nest WiFi Pro supports Matter and Thread so you can control your smart home from the Google Home app When I opened the app after installing the new hardware it asked if I wanted to connect to my Philips Hue and iRobot products You ll still need to have your Hue Bridge connected however so you re not saving a plug on your Ethernet switch That s unfortunate compared to say some Eero models which have built in Zigbee units that allow you to ditch the bridge entirely But if you re all in on Google s Assistant then you ll benefit from having everything hooked up inside one app A key selling point of Google s network products is the promise to keep them up to date with software and security updates The company has rolled out fairly regular updates over the last seven years and there s no indication yet that it s going to stop I ve been fairly happy with the work done for my first generation Google WiFi pucks If I do have a concern it s that Google sometimes axes products not long after launch so you do run the risk of investing in the company only for its impatience to get the better of it App and controlsI preferred when you could control your Google WiFi through the standalone app but these days it s all rolled into the company s Home app That s great as a one stop shop for any compatible smart home gadgets you might have but it s less comprehensive When managing your network you can look at per device traffic set priority access or pause connection to any device on the network You ll also be able to run speed and mesh connection tests to ensure that your network performance is optimal Some of these features aren t standard on other routers and some you need to pay extra to access Others may offer you a good deal more too If you re looking for more fine grain control you probably won t find it on the Nest As much as Google calls this a “Pro router it s more to gesture toward being more premium rather than for actual professionals There s no access to some of the harder core settings or browser based controls page for power users Instead this is a locked down curated experience for people who want their WiFi to work without much For parental controls you can set up groups within the Family WiFi menu to pause multiple devices at once You can also schedule access times a feature that several other mesh products expect you to pay to use And while there s no specific way to filter individual websites you can designate some hardware to be routed via Google s SafeSearch to block a broad swathe of content online What this system lacks is any fine grain control for concerned parents or the ability to monitor a specific device s browsing history But I ve always been of the opinion that overzealous parenting just creates kids who learn at a young age to hide what they ve been up to Wrap upWhat Google s WiFi products have always offered is a fairly acceptable blend of power price and performance You won t be getting into the nitty gritty parts of running a network but you re also not paying a huge amount of cash It should appeal to people who really don t want to worry about doing much more than running the odd speed test and quickly setting up a guest network without any stress Something like the TP Link XE might run faster and offer more features but for this price Google s remained true to its ethos of making the right compromises This article originally appeared on Engadget at 2023-06-21 13:00:29
海外科学 NYT > Science Endangered Species Act to Be Strengthened https://www.nytimes.com/2023/06/21/climate/biden-endangered-species-act.html changes 2023-06-21 13:35:39
金融 金融庁ホームページ 入札公告等を更新しました。 https://www.fsa.go.jp/choutatu/choutatu_j/nyusatu_menu.html 公告 2023-06-21 14:00:00
ニュース BBC News - Home Armed police respond to incident at London hospital https://www.bbc.co.uk/news/uk-england-london-65975166?at_medium=RSS&at_campaign=KARANGA london 2023-06-21 13:41:52
ニュース BBC News - Home Could Russia really play nuclear roulette in Ukraine? https://www.bbc.co.uk/news/world-europe-65976256?at_medium=RSS&at_campaign=KARANGA russian 2023-06-21 13:12:58
ニュース BBC News - Home Heineken Champions Cup: Last season's finalists La Rochelle and Leinster to meet in 2023-24 pool stage https://www.bbc.co.uk/sport/rugby-union/65970635?at_medium=RSS&at_campaign=KARANGA Heineken Champions Cup Last season x s finalists La Rochelle and Leinster to meet in pool stageLa Rochelle the Heineken Champions Cup winners and Premiership champions Saracens are among the clubs to learn their fate in the pool stage draw 2023-06-21 13:08:16
ニュース BBC News - Home Titan sub: What happens next after sounds detected in search https://www.bbc.co.uk/news/world-65972610?at_medium=RSS&at_campaign=KARANGA hours 2023-06-21 13:40:06
ニュース BBC News - Home Hamish Harding, Shahzada Dawood and son Suleman: Who is on board Titanic sub? https://www.bbc.co.uk/news/uk-65955554?at_medium=RSS&at_campaign=KARANGA titanic 2023-06-21 13:11:53
仮想通貨 BITPRESS(ビットプレス) 日本暗号資産ビジネス協会、理事の改選および新理事体制について https://bitpress.jp/count2/3_17_13653 資産 2023-06-21 22:12:52

コメント

このブログの人気の投稿

投稿時間: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件)