You are tasked to make a game of WAR! War is a card game played between two people. Each person gets half of a shuffled deck of cards. They both place the top card of their deck onto the field and the winner is the one whose card has the highest rank (Ace is counted as the highest card).
If both players place two cards down of the same rank the players go to war. The players again both draw a card and place it on the field. The winner of this bout wins all the cards on the field. If they both play the same rank again, you go to war again and keep drawing cards and comparing until one is clearly a winner. (In your program, you can make it so they can only go to war once. If they draw a second time you can return the players cards back to their original decks. )
As a player wins cards, he adds these cards to the bottom of his deck. You do not shuffle these cards that were won. A player wins when the other player has less than 10 cards in their deck.
This program needs to be coded from a grade 12 perspective. In other words, your program needs to include classes, objects and data structures.
Coding
You program should have three classes:
Deck Class
This class should create a data structure instance variable that supports a deck of 52 cards.
It should also have a method that populates this data structure with all 52 unique cards.
You should call this method on the creation of the deck (in the constructor!)
It should have a draw and remove card method. You can use Javas built in add(), remove(), pop(), push() etc.. methods inside the code of your methods.
You can use the Collections class shuffle method to shuffle this deck
playerDeck Class
This class should create a very specific type of data structure instance variable for the potential 26 cards the players deck can have.
It should have methods that handle drawing cards, inserting won cards, removing lost cards, detecting if the deck is empty, detecting if the player is below the minimum deck size (10 cards!).
For your insertion and removal methods, you can use Javas built in add(), remove(), pop(), push() etc.. methods inside the code of your methods.
Card Class
A typical card class similar to the ones we have made before in class
ach card has to have a rank and suit.
Have the rank eb an integer to simplify the code
Have a separate method that converts the rank number to strings for the jack, queen, king and ace
There should be a custom toString method
All classes should have mutators, accessors and at least one constructor.
Main Program:
The main program should utilize the previous classes and run the general flow of the game. You will need several methods to run your game: You will need a method that initializes the two 26 card playerDeck objects with the cards from the 52 card deck object. You will also need a method that runs the general flow of the game but also a method to handle when the players go to war during a draw.
The main program can be done many different ways so you will be assessed on how efficient and neat the main program is.
Post-Coding UML diagram
You need to include a UML diagram for your program that includes all three classes (you do not need to include the Main class). It should show all the instance variables, instance methods and the correct types of associations between the classes.
WPMU DEV’s Client Billing is perfect for creating and managing subscriptions, sending professional invoices, and providing your clients with an elegant white label portal where they can pay and manage their accounts (and websites, too).
This article covers all of the essentials of how to get the most out of Client Billing.
Everything we’ll be covering is accessible from the Client Billing tab located in the HUB, where there are several ways to access it.
One way is under the Client Billing tab, which is located on the menu bar.
It’s quickly accessible once in The Hub.
You can also easily access Client Billing on individually hosted sites from The Hub Overview and the upper right corner.
The choice is yours on how to access Client Billing.
You’ll need to have an account with us to get started with Client Billing. If you don’t have one, it’s simple to get started.
And with that, let’s begin!
1. Automating Your Client Billing and Management
As you’ll see, there are several ways to automate features in Client Billing. Automation is a great hands-off approach to focusing on growing and running your WordPress business instead of manually dealing with financial transactions and setting up paperwork.
We’ll touch on what you can do and give you a glimpse of how it’s done!
Automated Subscriptions
Recurring payments are the best way to “set it and forget it” when billing customers for services or products. It automates sending invoices, so you don’t have to collect payments manually.
Subscriptions can include hosting, site maintenance, updates – whatever you’d like. Essentially, anything that will be recurring for your business, you can automate the payment.
Get started with a new subscription by simply heading to the Products & Services area and clicking New Product.
This will get you started with a new subscription.
Create a Product Name, and you can also include an image.
We’ll set this one up to include a hosting service.
Give your product or service a Plan Name, Price, and Billing Type (recurring or one-time).
For one-time payments – that’s it! No more information is needed.
With the recurring plan, you can add how often to charge in the Bill Every area (e.g. one month). Plus, add an appropriate billing cycle.
You can choose between days, weeks, months, and years for billing!
Duplicate a plan by clicking the ellipsis, and you’re all set!
You can duplicate a plan as many times as you want. Delete the plan from here, too.
Once your plan is added, you can attach it to any customers you have in your dashboard. The plan name can be tweaked and updated at any time, too.
As clients get added to your Hub, you can instantly bill them on a per-site basis.
This is how you quickly send an invoice for a client; whether you created new features to their WordPress site, added some new security features to their existing site, or whatever the reason for billing is – to bill a client is as efficient as ever.
It’s all done by clicking on Bill Client in the upper right corner.
The Bill Client button is located in several areas throughout Client Billing.
Instantly bill a client by pulling them from the Client dropdown. And if you want, choose a website that they’re associated with.
All of your clients are located here.
Choose a product or service you want to bill for. The quantity and the amount will be displayed. Plus, add as many products and services as you’d like. Also, you can include tax and specify what it’s for and the rate.
For this example, it’s $25 a month for a hosting plan.
From here, you can…
Invoice in a Click
Once your information is entered, you can look at your invoice and send it in one click by tapping Send Invoice. Additionally, include a personalized message to it if you’d like.
Save it as a draft, preview, or you can send the invoice if ready.
Want to see what the invoice looks like before sending it? That’s no problem. Just click Preview, and you’ll get a PDF that you can view or download.
Everything looking up to par? You’re ready to send it to your client! Or, go back and edit anything.
Once sent, having your clients pay is easy as ever. Your client will receive an email to pay it online directly in their client portal (which we’ll get into later on in this article).
Monitor your invoices and see what’s paid, what’s not, and any drafts you have on the client’s page under Invoices.
The newest one on top states Payment Due.
As you can see, it takes just a few seconds to get an invoice ready and sent when you put it all together.
Client Management automatically tracks recurring revenue, so you don’t miss a beat when it comes to knowing your profits.
There are several ways to do this. For starters, to get a quick glimpse at your Monthly Recurring Revenue (MRR), simply check it out from the Client Billing Overview in the Revenue area. Here, it’ll give you the total amount of what you’re bringing in monthly.
You can also see the number of active subscriptions.
Take a look at what individual clients’ MRR is by going to their profile and viewing their Overview. In the Billing Stats, you can see how much MMR that particular client is bringing in.
This client is bringing in $90 in MRR.
See in detail what exactly is bringing in the income. Simply click on Products & Services. From here, you can view Current Subscriptions, One Time (payments), and Inactive Subscriptions.
It will also indicate if anything is Past Due and what’s Active. Additionally, you’ll see the amount it’s bringing in, the Number of Products, the Website it’s for, and the Next Renewal date.
Uh-oh. The red indicates that one of these subscriptions is past due.
Anytime a new subscription is added, it will automatically include it to Client Billing – in the Overview and on individual clients’ profiles.
2. Branded Invoices and Emails
Keeping your brand look, design, and information consistent throughout your billing is vital. It makes it clear that you’re established and professional. Luckily, Client Billing has a one-setup way of going about it.
All of this is done from the Configurations section.
Adding Your Brand
Include your brand and company information for invoices and emails in just a few steps. Go to Business Profile to start things off.
Get directly to your Business Profile from the Client Billing Overview.
Begin by adding your company logo in the Branding area.
In this example, we added a WPMU DEV logo.
Jazz things up a notch by including a Brand Color. You can use the color picker or enter a color code.
What color fits your company best?
Include all the Business Info you’d like, including your name, email, website, contact number, and more.
Put in all the prominent information needed.
Once saved, all of this information can be included on invoices and emails. You can go back in at any time to make edits as needed.
Customizing Invoices
Customizing your invoices adds credibility and professionalism to your business – and makes you stand out. It also helps you get recognized easier and paid quicker since you’ll become a familiar brand.
And you can do this quickly and easily by going to Customize Invoices.
Customization is a click away!
Choose the Invoice Number Format you’d like to use. From here, it will structure and number your invoices going forward.
Create a prefix that suits you well.
Want to add a personalized message to your invoice? Or more business information or a helpful memo? Do so with the Invoice Footer Note.
Include any message you’d like to it.
Choose specific Invoice Fields to use on your invoices.
Select all that you want to include.
Preview the invoice to get a nice idea of what it will look like for your clients.
Looking good!
And just like that, your invoices are ready to be implemented throughout your entire organization!
Personalized Emails
Like with invoices, personalized emails let your clients know you mean business. It’s another opportunity for them to become familiar with your brand.
This is simple to do from the Email Notifications section.
This is where you start to make your email stand out.
From here, one click will include your branding into your emails! Just flip the switch in Business Branding, and it will add your logo and color.
One-click is all it takes.
Include an Emails Footer Note as well. This will appear at the bottom of your email.
Your client’s billing experience is completely branded with your content in their Client Portal. Client’s can login to their Hub to pay bills, view orders, edit their information, and more!
Here’s a rundown of some of the essentials to get the most out of your client’s experience.
Client Login
The client has their own area in your Hub to log in to view their profile, including vital information about their billing (e.g. orders, bills, etc.). It provides a great customer experience and makes it easy for them to manage their billing on their end.
This is done with the help of the Hub Client plugin (which we’ll get into next).
From The Hub
Invite a new client to be added to your Hub by entering their information under the Client tab and New Client.
Click the button and you’re all set.
From here, you enter their information. (Please note that you can also import clients from Stripe. Information on how to do that can be found here.)
You pick what roles the user will have. For example, you can let the View All & Access Billing, Access Billing Only, and more – including adding custom user roles.
What user role do you want your client to have?
There’s also a Hub dropdown, where you select what Hub you want the client to access.
All set with their User Role and what Hub they’ll be using? Click the tab to Invite Client, and tab Add – and you’re all set. Your new client will get a login invitation. More information on setting this up is found in our documentation.
Your client can then open the email and set up a username and password by clicking Confirm Information. This email contains all the branded information we covered earlier in this article, plus the Client’s name (or business).
You can see below where your information will be incorporated.
All of your personal information that you want to include will be in the email invitation.
The client will be taken to a field where their email address is prepopulated. They just create a password, and that’s it! Also, if they’re a current WPMU DEV member, they’ll be sent to their already established account but with access to Client Billing.
Here’s an example of the login area for your new client.
Let’s amp things up a bit and check out what the login is like for a client…
With the Hub Client Plugin
For the ultimate white-label experience, you’ll need the Hub Client plugin, which is designed to provide your clients with an entirely white-labeled WPMU DEV experience on your domain.
The Hub Client plugin adds an even more white-labeled experience – all on your site.
You can completely white label The Hub, run on your site, bill and manage clients, and control users’ access levels.
Once activated on your site, you’re able to include custom logos, colors, and more.
There are even more configurations than what’s shown above!
Your client will log in to their portal, which includes nothing but your branding. In this example below, we’ve added Dev Man…
The login is yours to make however you want the clients to see it.
You can always get back into the Hub Client dashboard and make changes at any time. Read all about implementing and using the Hub Client Plugin in our documentation.
Client Payments
Now that your client has access, it’s quick and easy for them to view and pay invoices. This makes the process streamlined, simple, and convenient for your client – and you.
When a client logs in, they can easily view their Billing Details. This is an overview of everything, including their Monthly Recurring Bill, Active Subscriptions, Billing Info, and more.
It’s a complete overview of what the client is being billed for.
Your client can do a ton from here. This includes changing or adding information, such as billing address, payment method, and email address.
Plus, it will immediately indicate if a payment is due with a number circled in red next to the Invoices tab.
There’s one payment due in this example.
The Invoice tab is where clients can pay their invoice, plus it shows what’s been paid already (indicated in green).
As you can see, once payment is paid, and another one is due.
When clicking a specific invoice, the client can view, pay, or download a PDF of it.
In this case, $25 is due for site maintenance.
When your client hits the Make Payment button, it will give them a Billing Summary of what they’re paying for and then an area for them to enter their payment information.
$25 gets this subscription started.
The invoice is processed, and you’ll get a notification on your end that it was paid.
4. Manage Clients, Payments, and Revenue
Client Billing has all the essentials to manage clients, payments, and revenue. Plus, your clients get the same treatment on their end, where they can view and pay invoices, edit their account information, and more.
Let’s get right into the gist of what all you can do, starting with…
Account Managment
Account Management is for you and the client to know what your billing looks like, manage subscriptions/purchases, and update information. There’s a lot that you both can do.
Your client can manage their accounts all in this portal. As we went over, they can add their information and view and pay invoices. Clients can also Change Passwords, set up Two Factor Authentication, and View profiles from their icon while logged in.
This is the view the client has.
They can also view their Products & Services. This shows active subscriptions, the number of products, the next renewal date, and when the purchase was created. Plus, they’re able to view Current Subscription, One Time, and Inactive Subscription from the tabs.
Clicking on a tab shows just those results.
Your client can even Request to Cancel an active subscription by clicking on the ellipsis next to it.
From the ellipsis, they can also view subscriptions and invoices.
That’s a glimpse at management from the client’s side; let’s take a look at what you’re capable of doing on your end.
Viewing and Editing Clients
Pulling up your roster of clients is quick and easy to access and manage. All of this is done from the Clients tab.
From here, you can pull up individual clients, view Account Statuses, add New Clients, get your MRR, and see your Net Billing. Plus, as you’ll see, much more.
All the clients are in one area.
As we discussed a bit ago, you can add a NewClient with a click.
One-click is all it takes!
Also, assign or change roles for each client under the Roles tab.
Set the default role here, too.
Even create your own custom roles! Just give it a name and click what you’d like the role to have access to.
Click whatever roles you’d like to include.
To get into more specific details of each client, you can click on them individually and manage the client in many different ways with the client’s Overview.
The Overview features Billing Stats (e.g. MRR, Active Subscriptions, Net Billing, etc.) and information about your client.
You can change the Primary Hub from here, User role, and edit necessary information (e.g. Contact Number, Name, etc.).
There’s a lot of information about the client – all on one page.
View what subscriptions your client has and what they’ve purchased under Products & Services. You’ll see what’s active, the amount of money being brought in, pending, next renewal, websites, and more.
Just like on the client-side, you can see Current Subscriptions, OneTime, and Inactive Subscriptions.
It also shows when a product or service was purchased.
From the Invoices tab, you can see what invoices are due, what’s been paid, the amount, and the invoice number.
Need to find an invoice? You can search for one by typing in the number, too.
Clicking on the individual invoice will pull it up. You can view the invoice in detail, add notes, get client information, resend it to the client, and more.
Offline Payments
Mark as Paid if, for example, your client mails you a check instead of paying online. After all, not every client might want to pay through the client portal.
This is all done from the ellipsis under individual invoices.
Click to mark this invoice paid.
You can also do this from the ellipsis in the detailed invoices…
Not every client may pay online, so it’s essential to mark an invoice paid if you get a check or other payment method.
Once clicking, you can choose a payment method, payment date, add a reference number, and even send a receipt to the client.
Once marked as paid, it will no longer show Past Due in your Hub.
And just like that, it will mark it as paid.
Refunds
Refunds happen, and you can quickly issue a refund for any product or service. Once payment has been made, you can give a refund, and it will go directly back to the payment method the client used.
It’s all done directly from the ellipsis dropdown.
As you can see, account management is streamlined, easy, and more convenient than ever thanks to Client Billing! A lot of it is automated for you, and all the tools are here to keep you and your clients organized. Plus, with the ability to white label everything and simplify the payment process, your business is all in one place.
To get a feel for seeing Client Billing in action, check out our example. This article takes you through the entire journey, using WPMU DEV and Client Billing. And for a detailed look at everything you can do with Client Billing, be sure to read our documentation.
Additionally, there’s a lot more on the way with client billing, including automated domain purchasing, other payment gateways, and more (that we’ll keep you posted on)!
For site management made simple, there’s nothing as fulfilling as our Client Billing! Give it a try today.
I feel like half of all “custom-designed radio buttons and checkboxes” do two things:
Make them bigger
Colorize them
I always think of SurveyMonkey for having big chunky radios and checkboxes. And indeed, just poking at their interface quickly, even internally, the app uses has those all over the place:
SurveyMonkey’s implementation appears to be pseudo-elements on a <label> element with icon fonts and such.
I think it’s worth noting that if that’s all you are doing, you might be able to do that with zero CSS trickery. Just… make them bigger and colorize them.
We’re so close to having some very simple CSS to accomplish the main use-case for custom checkboxes and radios. But no cigar, that is, unless you can bring yourself to just not care about the Safari UI (it is still perfectly functional, after all).
If you do need to give up and go for a completely custom design, Stephanie Eckles has got you covered:
In related news, I always think of a “toggle” UI control as a set of 2 radio buttons progressively enhanced, but it turns out <button> is the way, as Michelle Barker covers here. No native UI for slider toggle thingies, alas.
Fidel API, a provider of financial infrastructure services, has announced the launch of a new API that is designed to streamline connecting with real-time payment card data for the development of financial management products. The Transaction Stream API is free to test and the company has provided an updated sandbox environment for this purpose.
You get an extra-round-y appearance in Safari, which at one time matched the macOS look for search inputs, but not really anymore. I don’t hate the look, except…
Safari totally ignores the font-size you set on it, so careful about that. Unless you smash off the round-y look with -webkit-appearance: none—then you can, so probably 92% of all websites do this.
You get a little × icon inside the input (when it has a value) that clears it out. This is probably the best reason to use it, and mercifiully you get to keep it even after resetting the appearance.
You get the satisfaction of knowing that you’re using the semantically correct input type for the job, assuming you are building a thing that actually searches something.
You get past search terms with autocomplete. Browsers store those past search terms and offer a menu for autocompleting them. I’m trying to make this a list of things that are unique to search inputs, and I can prove this happens on non-search inputs. But hey, it does make the most sense on search inputs.
You get the pleasure of adding a role to the parent form (i.e. <form role="search">) because that helps assistive technology announce it as a search form.
You get to remember to add a proper <label> to the input. Just using a magnifying glass icon or just a placeholder alone won’t cut it, even though that’s what a lot of designs call for visually.
You get a super weird incremental attribute that sends a debounced search event to the DOM element itself. I guess that is useful for live search UX. But it’s non-standard and not in Firefox so probably don’t count on it (via Christian Shaefer).
Hello, I am quite new to python programming and I need help with writing a code to calculate distance matrix from a text file that contains something like this:
There’s more to color on the web than meets the eye, and it’s about to get a lot more interesting! Today, we’ll take a look at the best ways to use colors in a design system, and what we can expect from our colors in the not-too-distant future.
Well-Known Color Values
There are many different ways to define colors in CSS. CSS named colors are one of the simplest ways to color an element:
.my-element {
background-color: red;
}
These are very limited, and rarely fit the designs we are building! We could also use color hex (hexadecimal) values. This code gives our element a red background color:
.my-element {
background-color: #ff0000;
}
Unless you’re a color expert, hex values are very difficult to read. It’s unlikely you would be able to guess the color of an element by reading the hex value. When building a website we might be given a hex color value by a designer, but if they asked us to make it, say 20% darker, we would have a hard time doing that by adjusting the hex value, without a visual guide or color picker.
RGB
RGB (red, green, blue) notation is an alternative way of writing colors, giving us access to the same range of colors as hex values, in a much more readable form. We have an rgb() function in CSS for this. Colors on the web are additive, meaning the higher the proportion of red, green and blue, the lighter the resulting color will be. If we only use the red channel, the result is red:
.my-element {
background-color: rgb(255, 0, 0);
}
Setting the red, green and blue channels to the highest value will result in white:
rgb() and rgba() allow us to “mix” colors in our code to some extent, but the results can be somewhat unpredictable.
HSL
More recently, we have been able to use HSL (hue, saturation, lightness) values, with the hsl() and hsla() color functions. As a developer, these are far more intuitive when it comes to adjusting color values. For example, we can get darker and lighter variants of the same color by adjusting the lightness parameter:
.my-element {
background-color: hsl(0deg, 100%, 20%); // dark red
}
.my-element {
background-color: hsl(0deg, 100%, 50%); // medium red
}
.my-element {
background-color: hsl(0deg, 100%, 80%); // light red
}
The hue parameter represents the position on a color wheel, and can be any value between 0 and 360deg. The function also accepts turn units (e.g. 0.5turn), and unitless values.
Tip: Holding down SHIFT and clicking the color swatch in the inspector in Chrome and Firefox dev tools will toggle the color value between hex, RGB and HSL!
hsl() and hsla() lend themselves well to manipulation with custom properties, as we’ll see shortly.
currentColor
The currentColor keyword is worth a mention as another way of setting a color on an element that’s been around for a while. It effectively allows us to use the current text color of an element as a variable. It’s pretty limited when compared with custom properties, but it’s often used for setting the fill color of SVG icons, to ensure they match the text color of their parent. Read about it here.
Modern Color Syntax
The CSS Color Module Level 4 provides us with a more convenient syntax for our color functions, which is widely supported in browsers. We no longer need the values to be comma-separated, and the rgb() and hsl() functions can take an optional alpha parameter, separated with a forward slash:
.my-element {
/* optional alpha value gives us 50% opacity */
background-color: hsl(0 100% 50% / 0.5);
}
.my-element {
/* With no alpha value the background is fully opaque*/
background-color: hsl(0 100% 50%);
}
New CSS Color Functions
HWB
HWB stands for hue, whiteness and blackness. Like HSL, the hue can be anywhere within a range of 0 to 360. The other two arguments control how much white or black is mixed into that hue, up to 100% (which would result in a totally white or totally black color). If equal amounts of white and black are mixed in, the color becomes increasingly gray. We can think of this as being similar to mixing paint. It could be especially useful for creating monochrome color palettes
Why do we need LAB and LCH when we have HSL? One reason is that using LAB or LCH, gives us access to a much larger range of colors. LCH and LAB are designed to give us access to the entire spectrum of human vision. Furthermore, HSL and RGB have a few shortcomings: they are not perceptually uniform and, in HSL, increasing or decreasing the lightness has quite a different effect depending on the hue.
In this demo, we can see a stark contrast between LCH and HSL by hitting the grayscale toggle. For the HSL hue and saturation strips, there are clear differences in the perceptual lightness of each square, even though the “lightness” component of the HSL function is the same! Meanwhile, the chroma and hue strips on the LCH side have an almost-uniform perceptual lightness.
We can also see a big difference when using LCH color for gradients. Both these gradients start and end with the same color (with LCH values converted to the HSL equivalents using this converter). But the LCH gradient goes through vibrant shades of blue and purple in the middle, whereas the HSL gradient looks muddier and washed-out by comparison.
LAB and LCH, while perhaps being syntactically a little less intuitive, behave in a way that makes more sense to the human eye. In her article, LCH color in CSS: what, why, and how?, Lea Verou explains in detail the advantages of LCH color. She also built this LCH color picker.
As with other color functions, hwb(), lab() and lch() can also take an optional alpha parameter.
.my-element {
background-color: lch(80% 240 50 / 0.5); // Resulting color has 50% opacity
}
Browser Support And Color Spaces
hwb(), lab() and lch() are currently only supported in Safari. It’s possible to start using them straight away by providing a fallback for non-supporting browsers. Browsers that don’t support the color function will simple ignore the second rule:
.my-element {
background-color: lch(55% 102 360);
/* LCH color converted to RGB using Lea Verou’s tool: https://css.land/lch/ */
background-color: rgb(98.38% 0% 53.33%);
}
If other styles depend on newer color functions being supported, we could use a feature query:
.my-element {
display: none;
}
/* Only display this element if the browser supports lch() */
@supports (background-color: lch(55% 102 360)) {
.my-element {
display: block;
background-color: lch(55% 102 360);
}
}
It’s worth noting, as Lea explains in her article, that although modern screens are capable of displaying colors beyond RGB, most browsers currently only support colors within the sRGB color space. In the LAB color demo you might notice that moving the sliders beyond a certain point doesn’t actually affect the color, even in Safari where lab() and lch() are supported. Using values outside of the sRGB range will only have an effect when hardware and browsers advance sufficiently.
Safari now supports the color() function, which enables us to display colors in the P3 space, but these are limited to RGB colors for now, and don’t yet give us all the advantages of LAB and LCH.
.my-element {
background: rgb(98.38% 0% 53.33%); // bright pink
background: color(display-p3 0.947 0 0.5295); // equivalent in P3 color space
}
Once they are widely supported, perhaps LAB and LCH can help us choose more accessible color combinations. Foreground text should have the same contrast ratio with background colors with different hue or chroma values, as long as their lightness value remains the same. That’s certainly not the case at the moment with HSL colors.
Color Management
A wider range of color functions means we have more options when it comes to managing colors in our application. Often we require several variants of a given color in our design system, ranging from dark to light.
Custom Properties
CSS custom properties allow us to store values for reuse in our stylesheets. As they allow partial property values, they can be especially useful for managing and manipulating color values. HSL lends itself particularly well to custom properties, due to its intuitiveness. In the previous demo, I’m using them to adjust the hue for each segment of the color strip by calculating a --hue value based on the element’s index (defined in another custom property).
We can also do things like calculate complementary colors (colors from opposite sides of the color wheel). Plenty has been written about this, so I won’t cover old ground here, but if you’re curious then Sara Soueidan’s article on color management with HSL is a great place to start.
Migrating From Hex/RGB To HSL
RGB colors might serve your needs up to a point, but if you need the flexibility to be able to derive new shades from your base color palette then you might be better off switching to HSL (or LCH, once supported). I would recommend embracing custom properties for this.
Note: There are plenty of online resources for converting hex or RGB values to HSL (here’s one example).
Perhaps you have colors stored as Sass variables:
$primary: rgb(141 66 245);
When converting to HSL, we can assign custom properties for the hue, saturation and lightness values. This makes it easy to create darker or lighter, more or less saturated variants of the original color.
HSL can be incredibly useful for creating color schemes, as detailed in the article Building a Color Scheme by Adam Argyle. In the article he creates light, dark and dim color schemes, using a brand color as a base. I like this approach because it allows for some fine-grained control over the color variant (for example, decreasing the saturation for colors in the “dark” scheme), but still retains the big advantage of custom properties: updating the brand color in just one place will be carried through to all the color schemes, so it could potentially save us a lot of work in the future.
Sass Color Functions
When it comes to mixing and adjusting colors, Sass has provided color functions to enable us to do just this for many years. We can saturate or desaturate, lighten or darken, even mix two colors together. These work great in some cases, but they have some limitations: firstly, we can only use them at compile-time, not for manipulating colors live in the browser. Secondly, they are limited to RGB and HSL, so they suffer from the same issues of perceptual uniformity, as we can see in this demo, where a color is increasingly desaturated yet appears increasingly lighter when converted to grayscale.
To ensure that the lightness remains uniform, we could use custom properties with LCH in a similar way to HSL above.
One thing CSS doesn’t yet allow us to do is mix colors in the browser. That’s all about to change: the Level 5 CSS Color Specification (working draft) contains proposals for color mixing functions that sound rather promising. The first is the color-mix() function, which mixes two colors much like Sass’s mix() function. But color-mix() in CSS allows us to specify a color space, and uses the LCH by default, with superior mixing as a result. The colors don’t have to be LCH when passed in as arguments either, but the interpolation will use the specified color space. We can specify how much of each color to mix, similar to gradient stops:
.my-element {
/* equal amounts of red and blue */
background-color: color-mix(in lch, red, blue);
}
.my-element {
/* 30% red, 70% blue */
background-color: color-mix(in lch, red 30%, blue);
}
Color Contrast And Accessibility
color-contrast() is another proposed function, which really does have huge implications for picking accessible colors. In fact, it’s designed with accessibility in mind first and foremost. It permits the browser to pick the most appropriate value from a list, by comparing it with another color. We can even specify the desired contrast ratio to ensure our color schemes meet WCAG guidelines. Colors are evaluated from left to right, and the browser picks the first color from the list that meets the desired ratio. If no colors meet the ratio, the chosen color will be the one with the highest contrast.
.my-element {
color: wheat;
background-color: color-contrast(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to AA);
}
Because this isn’t supported in any browsers right now, I’ve borrowed this example directly from the spec. when the browser evaluates the expression the resulting color will be darkgreen, as it is the first one that meets the AA contrast ratio when compared to wheat, the color of the text.
Browser Support
The Level 5 Color Specification is currently in Working Draft, meaning no browsers yet support the color-contrast() and color-mix() functions and their syntax is subject to change. But it certainly looks like a bright future for color on the web!
Environmental Impact Of Colors
Did you know that your chosen color palette can have an impact on how much energy your website uses? On OLED screens (which account for most modern TVs and laptops), darker colors will use significantly less energy than light colors — with white using the most energy, and black the least. According to Tom Greenwood, author of Sustainable Web Design, blue is also more energy-intensive than colors in the red and green areas of the spectrum. To reduce the environmental impact of your applications, consider a darker color scheme, using less blue, or enabling a dark-mode option for your users. As an added bonus, a more environmentally friendly choice of colors can also reduce the impact on the battery life of mobile devices.
Tools
Hexplorer, Rob DiMarzo Learn to understand hex colors with this interactive visualization.
LCH color picker, Lea Verou and Chris Lilley Get LCH colors and their RGB counterparts.
HWB color picker Visualize HWB colors and convert to HSL, RGB and hex.
Ally Color Tokens, Stephanie Eckles An accessible color token generator.
Chris and Shaw talk about how CodePen uses Cloudflare Works with the KV storage to power several things on CodePen. We do some cool stuff with them, like serve landing pages with the content provided by WordPress yet served on an entirely different Ruby on Rails powered site. We also serve up assets through them which provides lots of nice features both for us and for users indirectly and directly, like resizing and optimization.
Thanks to Jetpack for sponsoring CodePen Radio! Jetpack is a plugin, or perhaps now more like a suite of plugins, that help out your self-hosted WordPress site. Say you have a lot of WordPress sites under your purview and they all have different needs (super normal!). Jetpack has a new billing dashboard that helps manage at all in a sane way. Say you’ve got two sites that just need daily backup only, all good. Another that uses Jetpack Complete. Another where you use VideoPress and realtime backup, totally covered. You might have dozens or hundreds of sites if you manage client sites, and now this brings it all together in a manageable way.
I’d like to share a very simple, little effect with you. It’s just an idea for applying a filter effect on a slideshow when navigating between the images. This is really just a proof of concept, I haven’t made a second level interaction, so no content preview or such thing.
So I hope you enjoy just navigating between the slides and find some inspiration in this. The whole thing suffers from classitis, there’s lots of better ways to do this!
If your business is not online, you’re either not sold on the idea, or you’re living under a rock. The first place the average millennial looks to find products or services is not a store...
The performance of a machine learning model is first assessed based on its success rate. Then about the compatibility of this rate with business objectives.
A subject still little discussed in the business press, the key results indicators ( KPIs ) of machine learning models is nevertheless a central element in piloting an artificial intelligence project. In June 2020, an IDC study showed that around 28% of AI initiatives failed. Reasons given by the American cabinet are a lack of expertise, a lack of relevant data, and a lack of sufficiently integrated development environments. Intending to set up a process of continuous improvement of machine learning and avoid ending up in the wall, identifying KPIs is now a priority.
A recently published paper provides a logo and slick polish for an old vulnerability about the ability of certain Unicode characters to render differently for human reviewers than the machines that execute the instructions.
The code may intend to confuse a human reader to misunderstand the code based on how the compiler reads encoding (specifically Unicode characters). The intended result would be to execute something that an unconfused human would not allow.
A human code reviewer using a plain-text editor or editor with inaccurate syntax highlighting may miss the impact of these control characters. Most IDEs and code editors utilize parse trees and make the Unicode characters visible so that it’s easier for someone to understand.
Developers discussing this Trojan Source vulnerability may use the opportunity to saddle up on horse puns.
What Is the Trojan Source?
The Trojan Source is a combination of Unicode control characters that intend to confuse a human into thinking the code does one thing while getting the machine to do another. Mainly it involves the ability to change certain control characters like switching right-to-left encoding or to encode similar-looking letters in different character sets.
Looking for the best Black Friday and Cyber Monday deals on your favorite WordPress products?
The next few days are the perfect time to buy premium WordPress plugins, themes, web hosting, and tools to grow your business. As always, to help you find the best deals, we have created the ultimate listed of best WordPress Black Friday and Cyber Monday deals for 2021. Some of these are exclusive just for WPBeginner readers.
In the first part, create a Multi-tenancy Application In Nest.js - Part 1, we set up the Nest.js framework and configured and tested the microservices architecture application using Nest.js. In its second part, we used Sequelize and Mongoose to access the database and tested for both MySQL database and MongoDB.
Async Connection
In this part; we will see how to let the application connect to multiple databases depending on the request. Since it is a multi-tenancy application, each tenant has their own database containing their data accessing the same application, thus the application needs to connect to different databases. We will change the pass repository option method and use forRootAsync() instead of forRoot(), we need to use a custom class for configuration.
Nest gives us all the tools to work with any SQL and NoSQL database. You have a lot of options, you can also use almost all ORM and libraries in Nest.js and typescript, like Sequelize, TypeORM, Prisma, and of course mongoose.
In some cases, there may be a need to write the data stored in traditional databases to XML files. Iin Oracale, there are some XML functions for this subject, however, in this post, we'll discuss the alternative method for converting a table stored in an Oracle database to XML format within an Oracle database and exporting it as an XML file, without using Oracle's XML functions.
You can use that method in stored procedures in Oracle. Assume we have a table called Customer, which has the following columns:
Advanced analytics, business intelligence (BI), and the data that drives them are largely unused by the organizations that invest heavily in their promise. Industry insiders and analysts took notice of these trends and have reported on them regularly in recent years. According to Gartner, 97 percent of organizational data goes unused, and 87 percent of organizations have low levels of BI and advanced analytical maturity.
Many factors contribute to these challenges, and we're not going to pretend that we know them all or that there's an easy fix. Yet, our users have shown us that enhanced usability and a focused approach to analytics dashboard software can improve application stickiness.