IT |
ITmedia 総合記事一覧 |
[ITmedia News] ChromeブラウザにF1マクラーレンチームのマシンを飾れるテーマ登場 |
https://www.itmedia.co.jp/news/articles/2210/01/news060.html
|
chrome |
2022-10-01 17:39:00 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
「POST Dev | ビジネスを変革するモダンフロントエンドの祭典」を視聴したのでまとめてみた |
https://qiita.com/tkdayo/items/64412b99a8c1e96b5af1
|
postdev |
2022-10-01 17:31:16 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
[Rails] ec2上でcronを使ってrakeタスクを定期実行 |
https://qiita.com/nichidai3_0514/items/8f1ae07be709dfda2b24
|
rubyrails |
2022-10-01 17:09:46 |
Azure |
Azureタグが付けられた新着投稿 - Qiita |
GPU付AzureVMの立ち上げにはドライバのインストールが必要 |
https://qiita.com/mmoriastron/items/7a8172073ad4ab602d8b
|
azurevm |
2022-10-01 17:42:48 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
[Rails] ec2上でcronを使ってrakeタスクを定期実行 |
https://qiita.com/nichidai3_0514/items/8f1ae07be709dfda2b24
|
rubyrails |
2022-10-01 17:09:46 |
海外TECH |
MakeUseOf |
6 Free Travel Journal Apps to Create a Beautiful Trip Diary |
https://www.makeuseof.com/free-travel-journal-apps-create-trip-diary/
|
diary |
2022-10-01 08:30:14 |
海外TECH |
DEV Community |
TailwindCSS Explained! |
https://dev.to/dboatengx/tailwindcss-explained-lc9
|
TailwindCSS Explained TailwindCSS is a CSS framework for rapidly building custom UIs and design components without writing CSS code To understand why over currently live websites use TailwindCSS this article walks you through how to set up Tailwind inside your HTML project from scratch But before we hop into the real deal let s briefly tour what exactly TailwindCSS is What is TailwindCSS TailwindCSS is a utility first CSS framework meaning you can style page elements directly in your HTML code using utility classes Utility classes are pre existing classes that you can use to build custom UIs without having to write CSS code You can use utility classes to control the color layout spacing typography etc of page elements For instance let s say you want to create a simple card that has a title and some text Here s the HTML code you d use lt div class bg red p w rounded md gt lt h class text xl font medium mb gt Card title lt h gt lt p gt Lorem ipsum dolor sit amet consectetur adipisicing elit Maxime mollitia molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio eaque rerum lt p gt lt div gt The above HTML code contains utility classes bg red This class sets the background color of the card to light red p This class sets the horizontal and vertical padding of the card to units w This class sets the width of the card to of the available window space rounded md This class sets the border radius of the card so it has rounded edges text xl This class sets the text size of the title as times extra large font semibold This class sets the font weight of the title to semibold mb This class sets the bottom margin of the title to units This will produce the results below Learning TailwindCSS involves familiarizing yourself with several utility classes Once you do you can quickly build any custom component of your choice without hassle Why Use TailwindCSS Let s understand why TailwindCSS may be a better choice for your next project than other CSS frameworks The following presents some significant benefits of using Tailwind Helps build unique web pages and applications Tailwind is a low level language meaning in contrast to other CSS frameworks such as Bootstrap Tailwind does not provide you with fully styled components like modals buttons navbars etc Instead it provides utility classes that you can use to create your own unique custom UIs This gives you more flexibility and control over how you want your site or application to look No need to invent class names One of the things most developers hate about writing custom CSS code is having to name a whole lot of classes Picking the perfect class name or even remembering long complicated ones like card inner wrapper div can sometimes be pretty annoying But Tailwind solves this problem by providing you with utility classes where you just choose from a set of existing classes Increases development speedBecause you don t have to spend an indeterminate amount of time choosing the perfect class name and also do not have to switch between your HTML and CSS files multiple times Tailwind is much faster to work with than most CSS frameworks and definitely quicker than writing custom CSS Adding TailwindCSS to your projectThere are several ways you can set up TailwindCSS These include Method Using TailwindCSS CDNMethod Using Node Package Manager NPM Method Using TailwindCSS CDNTo start using TailwindCSS in your project you can just include the following link in the lt head gt tag of your HTML code lt link href dist tailwind min css rel stylesheet gt After that you can start using Tailwind s utility classes to build UIs Adding Tailwind to your project via CDN is very easy and beginner friendly It allows you to quickly start using Tailwind in your project without any configuration However there are some limitations associated with this method You cannot customize Tailwind s default theme The CDN file loads the complete utility classes in Tailwind causing the browser to load many unnecessary resources Specific directives like apply and variants which can help clean up your TailwindCSS code can t be used You can t install third party plugins Method Using Node Package ManagerAlthough the fastest and easiest way to set up TailwindCSS is via CDN it is highly recommended that you always use the NPM method This is because it allows you to access Tailwind s full functionalities and benefits Before installing Tailwind via NPM you need to install node on your device Open a terminal and run the following command to check if node is available on your machine node vWhen you have node installed the command will return the version of node that you have On my device it returned the following v On the other hand if you don t have node installed you can go to their official website and download it Let s now start setting up Tailwind Step Create a projectTo get started you need to create a project folder by running the following command in your terminal mkdir tailwind project Now change into the new directory and create a new folder Let s name it src This folder would contain the main CSS file change into new directorycd tailwind project create new foldermkdir src Step Create an NPM Configuration fileYou can now go ahead and initialize a package json file by running the following NPM command in the root directory of your project npm init yThe package json file will record all significant information about your project and the dependencies you would install Step Install TailwindCSSHere you would install the latest version of TailwindCSS You can do this by running the following command npm install D tailwindcssThe above command will make TailwindCSS available in your node modules folder Also D ensures that the Tailwind dependency is recorded and saved to package json Step Setup Tailwind Configuration FileAs mentioned earlier the most recommended way to set up Tailwind is via NPM One of the primary reasons is that it enables you to create a Tailwind configuration file that allows you to customize the default theme of TailwindCSS This is a massive advantage as you can use it to modify Tailwind s utility classes based on your needs Run the following command to create a Tailwind config file npx tailwindcss initBy running the above command a new file tailwind config js will be created with the following code type import tailwindcss Config module exports content theme extend plugins The content section of the Tailwind config file is where you d configure the paths to all your HTML templates JavaScript components and any other source files containing some Tailwind utility classes Inside the content section of the tailwind config js file you can add the path to your HTML file as shown below module exports content place path here theme extend plugins Step Add Tailwind directives to your Main CSS fileInside the src folder you created earlier create your main CSS file input css and add the following tailwind directives tailwind base tailwind components tailwind utilities The above directives represent three different layers in Tailwind The base layer can be used to add your own default base styles for specific HTML elements The components layer can be used to add custom classes to Tailwind that you want to be able to override with utilities The utilities layer can be used to add your own custom utility classes to Tailwind Step Processing TailwindCSSHere you will run a Tailwind CLI command to build your CSS At the end of the build process a new CSS file output css will be created This file contains the CSS variables needed for Tailwind to work npx tailwindcss i src input css o dist output css watchFrom the above CLI command src input css represents your main CSS file dist output css represents the template path for where the output css file will be placed after the build process Instead of writing the lengthy CLI command above every time you can just add the following script to package json package json scripts build css tailwindcss i src tailwind css o public tailwind css ー watch Now you can just build the CSS using the command below npm run build css Step Link StylesheetCreate an index html file in your root project directory and include a link to output css in the lt head gt tag of your HTML code lt link href dist output css rel stylesheet gt Congrats you ve successfully installed Tailwind inside an HTML project Building a Simple Card Using Tailwind CSSHere you ll start using Tailwind s utility classes by creating the simple form shown in the image below In your index html create a form wrapper to contain all the HTML code for the form lt form class bg gray w p rounded md max w md gt lt h class text center text xl font semibold gt Simple Form lt h gt lt label for lastName gt Full name lt label gt lt input type text id lastName name lastName class w full rounded sm outline none px py gt lt br gt lt label for email gt Email lt label gt lt input type email id email name email class w full rounded sm outline none px py gt lt br gt lt label for email gt Message lt label gt lt textarea class w full rounded sm h resize none outline none px gt lt textarea gt lt br gt lt br gt lt input id submit type submit value Submit class w full py rounded sm cursor pointer hover bg gray gt lt form gt The final live result of the project can be viewed on this codepen ConclusionIn this TailwindCSS tutorial you learned Definition of TailwindCSS Benefits of using TailwindCSS Setting up TailwindCSS using various methods Building a simple form with Tailwind s utility classes One thing to note about the project you just created is how you added the utility classes to your HTML code You ll notice that as the complexity of your styling grows the code will get untidy In my next article I ll tackle how to clean up your TailwindCSS code with a complete demo project To learn more about TailwindCSS head over to their documentation page I hope this has been a worthwhile read Kindly share this article and follow me on Twitter dboatengx for updates on future posts |
2022-10-01 08:39:59 |
海外TECH |
DEV Community |
Abstract Factory pattern in TypeScript |
https://dev.to/jmalvarez/abstract-factory-pattern-in-typescript-6c8
|
Abstract Factory pattern in TypeScript IntroductionThe abstract factory pattern is a creational pattern which provides you with an interface for creating families of related objects without specifying their concrete classes As long as the objects are created using the factory you don t have to worry about creating the wrong combination of objects ApplicabilityWhen a set of objects should be used togetherWhen the application should be independent of how the objects are createdIf you have a class with multiple Factory Methods consider switching to an Abstract FactoryIf the types of the products are unknown beforehand or can change dynamically ImplementationYou can find the full example source code here Define an abstract interface for each object of the family of objects that the factory will create In our example we have two kinds of objects Orders and Payments interface Order id number addProduct productId string void addShippingAddres address string void interface Payment addCreditCardNumber ccNumber number void completePayment order Order boolean Define all the variants of each object These variants will implement the interfaces defined on the previous step For our example we have two variants Online and Physical So we have to create the following classes OnlineOrder OnlinePayment PhysicalOrder and PhysicalPayment Order object Online variant class OnlineOrder implements Order id number constructor id number this id id addProduct productId string void console log Product productId added to the online order addShippingAddres address string void console log Shipping address address added to the online order Order object Physical variant class PhysicalOrder implements Order id number constructor id number this id id addProduct productId string void console log Product productId added to the physical order addShippingAddres address string void console log Shipping address address added to the physical order Payment object Online variant class OnlinePayment implements Payment addCreditCardNumber ccNumber number void console log Credit card number ccNumber added to the online payment completePayment order OnlineOrder boolean console log Payment completed for the online order order id return true Payment object Physical variant class PhysicalPayment implements Payment addCreditCardNumber ccNumber number void console log Credit card number ccNumber added to the physical payment completePayment order PhysicalOrder boolean console log Physical payment completed for the physical order order id return true Define the Abstract Factory which is an interface with a list of methods that will create the objects These methods should have as a return type the interfaces of the products that we defined in the first step Our abstract factory has to define two methods one to create orders and another one to create payments interface CommerceFactory createOrder id number Order createPayment Payment A new class that implements the Abstract Factory has to be created for each variant of the family of objects In our example we have to create one factory for the online variant and another one for the physical variant Factory for the Online variant class OnlineCommerceFactory implements CommerceFactory createOrder id number Order return new OnlineOrder id createPayment Payment return new OnlinePayment Factory for the Physical variant class PhysicalCommerceFactory implements CommerceFactory createOrder id number Order return new PhysicalOrder id createPayment Payment return new PhysicalPayment The factories are ready to be used An instance of a factory has to be passed to the client code to start creating new objects An example of how client code would create objects for the online variant const onlineCommerceFactory new OnlineCommerceFactory const onlineOrder onlineCommerceFactory createOrder const onlinePayment onlineCommerceFactory createPayment onlineOrder addProduct onlineOrder addShippingAddres Main St onlinePayment addCreditCardNumber onlinePayment completePayment onlineOrder An this is how the client would use the physical variant const physicalCommerceFactory new PhysicalCommerceFactory const physicalOrder physicalCommerceFactory createOrder const physicalPayment physicalCommerceFactory createPayment physicalOrder addProduct physicalOrder addShippingAddres Main St physicalPayment addCreditCardNumber physicalPayment completePayment physicalOrder It s important that the client code uses the abstract interfaces and not the concrete classes This lets us change the family of objects that are returned dynamically without modifying or breaking client code and it isolates the client from concrete implementations The client can work with any family of objects as longs as it uses the abstract interfaces AdvantagesImproves consistency making sure that the products that are created using a factory will always be compatible with each other Client code is isolated from concrete implementations Single Responsibility Principle All the object creation code is placed together Open Closed Principle New families of objects can be introduced without breaking client code As always make sure it makes sense to use this pattern in your application Otherwise you could be introducing unnecessary complexity ResourcesExample source codeAbstract Factory refactoring guruSingle Responsibility PrincipleOpen Closed Principle |
2022-10-01 08:36:55 |
ニュース |
BBC News - Home |
Train strike: Worst rail disruption of year as workers walk out |
https://www.bbc.co.uk/news/business-63087621?at_medium=RSS&at_campaign=KARANGA
|
workers |
2022-10-01 08:02:33 |
ニュース |
BBC News - Home |
London Marathon 2022: Everything you need to know - who is taking part and what time does it start? |
https://www.bbc.co.uk/sport/athletics/63074801?at_medium=RSS&at_campaign=KARANGA
|
London Marathon Everything you need to know who is taking part and what time does it start The London Marathon is almost upon us Here is everything you need to know as runners prepare to tackle the iconic course |
2022-10-01 08:10:49 |
ビジネス |
不景気.com |
富山の養鶏業「床鍋養鶏」が自己破産申請へ、負債20億円 - 不景気com |
https://www.fukeiki.com/2022/10/tokonabe-egg.html
|
富山県小矢部市 |
2022-10-01 08:58:33 |
ビジネス |
不景気.com |
愛媛の食肉販売「ミート伊藤」が自己破産申請へ、負債3億円 - 不景気com |
https://www.fukeiki.com/2022/10/meat-ito.html
|
愛媛県伊予市 |
2022-10-01 08:31:19 |
ビジネス |
不景気.com |
富山の建設業「平松建設」に破産開始決定、負債2億円 - 不景気com |
https://www.fukeiki.com/2022/10/hiramatsu-kensetsu.html
|
富山県滑川市 |
2022-10-01 08:08:17 |
北海道 |
北海道新聞 |
道南117人感染 新型コロナ |
https://www.hokkaido-np.co.jp/article/739233/
|
医療機関 |
2022-10-01 17:13:00 |
北海道 |
北海道新聞 |
国連環境計画事務局長が広島訪問 「被爆の実相学び理解を」 |
https://www.hokkaido-np.co.jp/article/739232/
|
事務局長 |
2022-10-01 17:09:00 |
コメント
コメントを投稿