how to rotate image using c–

how to rotate image using c-- following this
byte[,] rotation(byte[,]f, float x0,float y0,float a); f is the input image, (x0,y0) is the rotating center & a is the rotating angle. Return value is the output image (using IM & Bilinear interpolation);

Contextually Display Content With the Block Injector Plugin

Jamie Marsland, the founder of Pootlepress, reached out a few weeks ago, asking for feedback on a beta version of Block Injector. It was a commercial plugin his team at Pootlepress was gearing up to launch. Earlier this week, they released an updated version that he said he was happy with as an initial release. For a first outing, it has proved to be a handy plugin.

The concept is not new. Plugins for dynamically injecting content in various places have long existed. In the past, these plugins have allowed users to create content through settings panels, widgets, or even the customizer. Some themes provide such options too. However, Block Injector is the first I have seen that takes this concept and moves it into the block arena.

The plugin creates a new post type for creating injectable content. Essentially, users can add any blocks they want via the editor and display them at a custom location on the front end.

Editor view of the Block Injector plugin and custom-defined rulesets of where the content should appear.
Adding a coupon to show at the top of a specific post.

The plugin has four different conditional rulesets that users can define:

  • Location: Which pages of the site the content appears on.
  • Position: Where on the page the content should display.
  • Exceptions: Post IDs to exclude.
  • Schedule: Date and time-based start and end dates.

Marsland published a six-minute video that breaks down how it all works:

After using Block Visibility, a dedicated plugin for contextually displaying blocks, it is hard not to see anything else as inferior. Its location-based logic provides more flexibility than most will ever need. I have become accustomed to its granular controls. Block Injector’s rules are limited in comparison but should work well for the majority of use cases. I almost want to merge them to see what I can create.

Block Injector really shines when paired with WooCommerce. The development team added several shop-specific location options. They also expanded on the positioning rules to utilize a range of WooCommerce hooks. This can create a powerful set of tools for store owners, particularly for seasonal sales. For example, users can display a coupon for the month leading up to Christmas.

Editor view of defining where to show a Block Injector post on a WooCommerce shop page.
Adding a coupon to show on the WooCommerce shop page.

One area where I hit a snag was with themes that had grid layouts on the homepage. When injecting content at the top or bottom, it would often get sucked into the post grid.

This issue is evident in the following screenshot when using the Flock theme:

My expectation was that it would have spanned the area above the posts. However, I am not sure how easy this would be to fix from the plugin’s end because there are only specific places where it is possible to hook into the front-end output. Attempting to correct this via CSS for all grid themes would be futile. However, as we continue to move toward 100% block themes in the future, it may open some alternative routes for injecting such content.

On the whole, I like the direction I am seeing from this first version. Having run theme and general WordPress support for over a decade, I had an untold number of users ask for similar solutions. I doubt there was a week that went by where I did not field such a question. Block Injector should save many a lot of time.

I would call the plugin necessary more so than particularly groundbreaking. The community needed someone to step up and build it for the block era.

Also, Marsland created a fake marketing video for the plugin if you are looking for a quick laugh:

That tweet is just one in a series of videos under the #WPFakes hashtag, one of my favorite things on the internet right now.

Version 1.0.1, the copy I am currently testing, does have a few PHP errors when WooCommerce is not active in specific scenarios. These are trivial to fix, and I have passed along the details to the team. However, I did want to note this to readers who might consider purchasing this for use without WooCommerce. I expect the problems will be fixed in the next release.

Writing Your Own Code Rules

There comes a time on a project when it’s worth investing in tooling to protect the codebase. I’m not sure how to articulate when, but it’s somewhere after the project has proven to be something long-term and rough edges are starting to show, and before things feel like a complete mess. Avoid premature optimization but avoid, uh, postmature optimization.

Some of this tooling is so easy to implement, it is often done right up-front. I think of Prettier here, a code formatter that keeps your code in shape, usually right as you are coding. There are whole suites of tools you can put in that “as-you-are-coding” bucket, like accessibility linting, compatibility linting, security linting, etc. Webhint bundles a bunch of those together and is probably worth a look.

Then there is tooling that protects your code via more code that you have to write. Tests are the big player here, which can even be set up to run as you code. They are about making sure your code does what it is meant to do, and as such, deliver a hell of a lot of value.

Protecting your code with more code that you write is where I wanted to go with this, not with traditional tests, but with custom linting rules. I thought about it as two different posts about custom linting crossed my desk recently:

I was interested as a user of both ESLint and Stylelint in my main codebase. But fair warning, I found the process for writing custom rules in both of those pretty difficult. You gotta know you way around an Abstract Syntax Tree. It’s nothing like if (rules.find.selector.startsWith("old")) throw("Deprecated selector.") or something easy like that.

I found this all related to an interesting question that came my way:

I work on a development team working on an old project, and we want to get of rid many of our oldest and buggiest CSS selectors. For example, one of us might open a HTML file and see an element with a class name of deprecated-selector, our goal is to have our IDE literally mark it as a linting error and say like “This is a deprecated selector, use .ui-fresh__selector instead”.

The first thing I thought of was a custom Stylelint rules that would look for selectors that your team knows to be deprecated and warn you. But unfortunately, Stylelint is for linting CSS and it sounds like the main issue here is HTML. I know html-inspector had a way to write your own rules, but it’s getting a bit long in the tooth so I don’t know if there is success to be found there or not.


The post Writing Your Own Code Rules appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.

Amazon Announces New AWS Cloud Control APIs

Amazon has announced a new suite of APIs that are intended to simplify the process of managing its myriad services programmatically, rather than manually. The new AWS Cloud Control APIs provide a unified way to Create, Read, Update, Delete, and List (CRUDL) resources across the platform. 

Amazon outlined an example use case for these APIs in stating that:

problem in C involving static queue.

can someone help me with this problem in C?

I'm new here I need help please help me with this question below.

Create a C program that performs a lookup for an X element in a queue
static. It is important to note that only the operations: queuing and unqueuing are allowed.
Print the position of element X in the queue if found or print the message "Element
not found, otherwise.

Default Theme Releases May Become More Frequent Following WordPress 5.9

photo credit: Matt Bango

The new Twenty Twenty-Two default theme coming in 5.9 hasn’t even been fully built yet but many WordPress enthusiasts who saw yesterday’s design reveal are already eager to use it on their sites. Contributors have just 40 days before the scheduled Beta 1 release on November 16 to get the theme ready. While that seems like an impossibly tight deadline, more frequent default theme releases may be ahead on the horizon.

In a couple of short paragraphs tucked into the end of the announcement, Kjell Reigstad commented on the future of default theme release frequency:

The community has produced a dozen best-in-class themes together, and we’ve come to look forward to a new one arriving at the close of each year. That said, themes are in a transition period today, and it seems like this may be a reasonable time to step back and to re-evaluate the annual cadence with which we build default themes. 

Innovations like theme.json, block templates, and block patterns are making theme development far simpler, and are providing new ways for users to customize their sites. There’s reason to believe that the community can leverage all this to build more frequent and diverse theme and customization solutions for our users in the coming years. 

It wasn’t clear whether Reigstad meant that the cadence of default theme releases would be slowing down or speeding up. I asked him for clarification and he confirmed that the idea is to consider the possibility of speeding up.

“I hope these new tools allow us to create and release more frequently than we’ve been able to in the past,” Reigstad said.

“The general idea came up as part of the ideation process for the default theme this year, and that part of the post is meant to give it a wider platform for conversation in the community. I’m excited to hear what other folks think since this idea is in its very early days! I really think there’s a lot of opportunity here.”

 The ideation process he referenced, which varies from year to year, included early conversations with project leadership to plan and make sure the theme is aligned with the future of WordPress.

Before the discussion officially kicks off regarding increasing default theme release frequency, contributors are focused on getting Twenty Twenty-Two out the door. Reigstad said people can jump in on testing now, as the general structure is already in place. This includes fonts, colors, and basic templates, although details like spacing and specific block styles are still in progress along with block patterns. If you want to contribute to making Twenty Twenty-Two the best it can be, check out the development happening on GitHub.

Angular 2 vs AngularJS for E-Commerce: What’s the Difference?

Both Angular 2 and AngularJS are great for e-commerce, but which one you use for e-commerce depends on your needs. AngularJS is good for building small-scale e-commerce applications fast while Angular 2 is good for complex, scalable solutions that are high-performing and mobile-ready. 

Today, over a quarter of developers use AngularJS and Angular 2. Thirty-two percent use them for user interfaces, according to StackOverflow, and many of the respondents in that study worked in e-commerce development.

Qi Theme

Qi Theme 21

Qi Theme is a free WordPress theme created by Qode Interactive – an award-winning studio. This theme perfectly combines top speed and performance with a beautiful design.

It comes with 100 demos, allowing you to easily set up any type of website, whether it’s an online store, an artist’s portfolio, or a simple blog. If you can think it up, this theme will help you build it – it will even grant you free access to premium stock photos.

Qi Theme is fully supported by video tutorials as well as an extensive knowledge base, so you’ll always have a place to look for help.

CSS in TypeScript with vanilla-extract

vanilla-extract is a new framework-agnostic CSS-in-TypeScript library. It’s a lightweight, robust, and intuitive way to write your styles. vanilla-extract isn’t a prescriptive CSS framework, but a flexible piece of developer tooling. CSS tooling has been a relatively stable space over the last few years with PostCSS, Sass, CSS Modules, and styled-components all coming out before 2017 (some long before that) and they remain popular today. Tailwind is one of a few tools that has shaken things up in CSS tooling over the last few years.

vanilla-extract aims to shake things up again. It was released this year and has the benefit of being able to leverage some recent trends, including:

  • JavaScript developers switching to TypeScript
  • Browser support for CSS custom properties
  • Utility-first styling

There are a whole bunch of clever innovations in vanilla-extract that I think make it a big deal.

Zero runtime

CSS-in-JS libraries usually inject styles into the document at runtime. This has benefits, including critical CSS extraction and dynamic styling.

But as a general rule of thumb, a separate CSS file is going to be more performant. That’s because JavaScript code needs to go through more expensive parsing/compilation, whereas a separate CSS file can be cached while the HTTP2 protocol lowers the cost of the extra request. Also, custom properties can now provide a lot of dynamic styling for free.

So, instead of injecting styles at runtime, vanilla-extract takes after Linaria and astroturf. These libraries let you author styles using JavaScript functions that get ripped out at build time and used to construct a CSS file. Although you write vanilla-extract in TypeScript, it doesn’t affect the overall size of your production JavaScript bundle.

TypeScript

A big vanilla-extract value proposition is that you get typing. If it’s important enough to keep the rest of your codebase type-safe, then why not do the same with your styles?

TypeScript provides a number of benefits. First, there’s autocomplete. If you type “fo” then, in a TypeScript-friendly editor, you get a list of font options in a drop down — fontFamily, fontKerning, fontWeight, or whatever else matches — to choose from. This makes CSS properties discoverable from the comfort of your editor. If you can’t remember the name of fontVariant but know it’s going to start with the word “font” you type it and scroll through the options. In VS Code, you don’t need to download any additional tooling to get this to happen.

This really speeds up the authoring of styles:

It also means your editor is watching over your shoulder to make sure you aren’t making any spelling mistakes that could cause frustrating bugs.

vanilla-extract types also provide an explanation of the syntax in their type definition and a link to the MDN documentation for the CSS property you’re editing. This removes a step of frantically Googling when styles are behaving unexpectedly.

Image of VSCode with cursor hovering over fontKerning property and a pop up describing what the property does with a link to the Mozilla documentation for the property

Writing in TypeScript means you’re using camel-case names for CSS properties, like backgroundColor. This might be a bit of a change for developers who are used regular CSS syntax, like background-color.

Integrations

vanilla-extract provides first-class integrations for all the newest bundlers. Here’s a full list of integrations it currently supports:

  • webpack
  • esbuild
  • Vite
  • Snowpack
  • NextJS
  • Gatsby

It’s also completely framework-agnostic. All you need to do is import class names from vanilla-Extract, which get converted into a string at build time.

Usage

To use vanilla-Extract, you write up a .css.ts file that your components can import. Calls to these functions get converted to hashed and scoped class name strings in the build step. This might sound similar to CSS Modules, and this isn’t by coincidence: the creator of vanilla-Extract, Mark Dalgleish, is also co-creator of CSS Modules.

style()

You can create an automatically scoped CSS class using the style() function. You pass in the element’s styles, then export the returned value. Import this value somewhere in your user code, and it’s converted into a scoped class name.

// title.css.ts
import {style} from "@vanilla-extract/css";

export const titleStyle = style({
  backgroundColor: "hsl(210deg,30%,90%)",
  fontFamily: "helvetica, Sans-Serif",
  color: "hsl(210deg,60%,25%)",
  padding: 30,
  borderRadius: 20,
});
// title.ts
import {titleStyle} from "./title.css";

document.getElementById("root").innerHTML = `<h1 class="${titleStyle}">Vanilla Extract</h1>`;

Media queries and pseudo selectors can be included inside style declarations, too:

// title.css.ts
backgroundColor: "hsl(210deg,30%,90%)",
fontFamily: "helvetica, Sans-Serif",
color: "hsl(210deg,60%,25%)",
padding: 30,
borderRadius: 20,
"@media": {
  "screen and (max-width: 700px)": {
    padding: 10
  }
},
":hover":{
  backgroundColor: "hsl(210deg,70%,80%)"
}

These style function calls are a thin abstraction over CSS — all of the property names and values map to the CSS properties and values you’re familiar with. One change to get used to is that values can sometimes be declared as a number (e.g. padding: 30) which defaults to a pixel unit value, while some values need to be declared as a string (e.g. padding: "10px 20px 15px 15px").

The properties that go inside the style function can only affect a single HTML node. This means you can’t use nesting to declare styles for the children of an element — something you might be used to in Sass or PostCSS. Instead, you need to style children separately. If a child element needs different styles based on the parent, you can use the selectors property to add styles that are dependent on the parent:

// title.css.ts
export const innerSpan = style({
  selectors:{[`${titleStyle} &`]:{
    color: "hsl(190deg,90%,25%)",
    fontStyle: "italic",
    textDecoration: "underline"
  }}
});
// title.ts
import {titleStyle,innerSpan} from "./title.css";
document.getElementById("root").innerHTML = 
`<h1 class="${titleStyle}">Vanilla <span class="${innerSpan}">Extract</span></h1>
<span class="${innerSpan}">Unstyled</span>`;

Or you can also use the Theming API (which we’ll get to next) to create custom properties in the parent element that are consumed by the child nodes. This might sound restrictive, but it’s intentionally been left this way to increase maintainability in larger codebases. It means that you’ll know exactly where the styles have been declared for each element in your project.

Theming

You can use the createTheme function to build out variables in a TypeScript object:

// title.css.ts
import {style,createTheme } from "@vanilla-extract/css";

// Creating the theme
export const [mainTheme,vars] = createTheme({
  color:{
    text: "hsl(210deg,60%,25%)",
    background: "hsl(210deg,30%,90%)"
  },
  lengths:{
    mediumGap: "30px"
  }
})

// Using the theme
export const titleStyle = style({
  backgroundColor:vars.color.background,
  color: vars.color.text,
  fontFamily: "helvetica, Sans-Serif",
  padding: vars.lengths.mediumGap,
  borderRadius: 20,
});

Then vanilla-extract allows you to make a variant of your theme. TypeScript helps it ensure that your variant uses all the same property names, so you get a warning if you forget to add the background property to the theme.

Image of VS Code where showing a theme being declared but missing the background property causing a large amount of red squiggly lines to warn that the property’s been forgotten

This is how you might create a regular theme and a dark mode:

// title.css.ts
import {style,createTheme } from "@vanilla-extract/css";

export const [mainTheme,vars] = createTheme({
  color:{
    text: "hsl(210deg,60%,25%)",
    background: "hsl(210deg,30%,90%)"
  },
  lengths:{
    mediumGap: "30px"
  }
})
// Theme variant - note this part does not use the array syntax
export const darkMode = createTheme(vars,{
  color:{
    text:"hsl(210deg,60%,80%)",
    background: "hsl(210deg,30%,7%)",
  },
  lengths:{
    mediumGap: "30px"
  }
})
// Consuming the theme 
export const titleStyle = style({
  backgroundColor: vars.color.background,
  color: vars.color.text,
  fontFamily: "helvetica, Sans-Serif",
  padding: vars.lengths.mediumGap,
  borderRadius: 20,
});

Then, using JavaScript, you can dynamically apply the class names returned by vanilla-extract to switch themes:

// title.ts
import {titleStyle,mainTheme,darkMode} from "./title.css";

document.getElementById("root").innerHTML = 
`<div class="${mainTheme}" id="wrapper">
  <h1 class="${titleStyle}">Vanilla Extract</h1>
  <button onClick="document.getElementById('wrapper').className='${darkMode}'">Dark mode</button>
</div>`

How does this work under the hood? The objects you declare in the createTheme function are turned into CSS custom properties attached to the element’s class. These custom properties are hashed to prevent conflicts. The output CSS for our mainTheme example looks like this:

.src__ohrzop0 {
  --color-brand__ohrzop1: hsl(210deg,80%,25%);
  --color-text__ohrzop2: hsl(210deg,60%,25%);
  --color-background__ohrzop3: hsl(210deg,30%,90%);
  --lengths-mediumGap__ohrzop4: 30px;
}

And the CSS output of our darkMode theme looks like this:

.src__ohrzop5 {
  --color-brand__ohrzop1: hsl(210deg,80%,60%);
  --color-text__ohrzop2: hsl(210deg,60%,80%);
  --color-background__ohrzop3: hsl(210deg,30%,10%);
  --lengths-mediumGap__ohrzop4: 30px;
}

So, all we need to change in our user code is the class name. Apply the darkmode class name to the parent element, and the mainTheme custom properties get swapped out for darkMode ones.

Recipes API

The style and createTheme functions provide enough power to style a website on their own, but vanilla-extract provides a few extra APIs to promote reusability. The Recipes API allows you to create a bunch of variants for an element, which you can choose from in your markup or user code.

First, it needs to be separately installed:

npm install @vanilla-extract/recipes

Here’s how it works. You import the recipe function and pass in an object with the properties base and variants:

// button.css.ts
import { recipe } from '@vanilla-extract/recipes';

export const buttonStyles = recipe({
  base:{
    // Styles that get applied to ALL buttons go in here
  },
  variants:{
    // Styles that we choose from go in here
  }
});

Inside base, you can declare the styles that will be applied to all variants. Inside variants, you can provide different ways to customize the element:

// button.css.ts
import { recipe } from '@vanilla-extract/recipes';
export const buttonStyles = recipe({
  base: {
    fontWeight: "bold",
  },
  variants: {
    color: {
      normal: {
        backgroundColor: "hsl(210deg,30%,90%)",
      },
      callToAction: {
        backgroundColor: "hsl(210deg,80%,65%)",
      },
    },
    size: {
      large: {
        padding: 30,
      },
      medium: {
        padding: 15,
      },
    },
  },
});

Then you can declare which variant you want to use in the markup:

// button.ts
import { buttonStyles } from "./button.css";

<button class=`${buttonStyles({color: "normal",size: "medium",})}`>Click me</button>

And vanilla-extract leverages TypeScript giving autocomplete for your own variant names!

You can name your variants whatever you like, and put whatever properties you want in them, like so:

// button.css.ts
export const buttonStyles = recipe({
  variants: {
    animal: {
      dog: {
        backgroundImage: 'url("./dog.png")',
      },
      cat: {
        backgroundImage: 'url("./cat.png")',
      },
      rabbit: {
        backgroundImage: 'url("./rabbit.png")',
      },
    },
  },
});

You can see how this would be incredibly useful for building a design system, as you can create reusable components and control the ways they vary. These variations become easily discoverable with TypeScript — all you need to type is CMD/CTRL + Space (on most editors) and you get a dropdown list of the different ways to customize your component.

Utility-first with Sprinkles

Sprinkles is a utility-first framework built on top of vanilla-extract. This is how the vanilla-extract docs describe it:

Basically, it’s like building your own zero-runtime, type-safe version of Tailwind, Styled System, etc.

So if you’re not a fan of naming things (we all have nightmares of creating an outer-wrapper div then realising we need to wrap it with an . . . outer-outer-wrapper ) Sprinkles might be your preferred way to use vanilla-extract.

The Sprinkles API also needs to be separately installed:

npm install @vanilla-extract/sprinkles

Now we can create some building blocks for our utility functions to use. Let’s create a list of colors and lengths by declaring a couple of objects. The JavaScript key names can be whatever we want. The values will need to be valid CSS values for the CSS properties we plan to use them for:

// sprinkles.css.ts
const colors = {
  blue100: "hsl(210deg,70%,15%)",
  blue200: "hsl(210deg,60%,25%)",
  blue300: "hsl(210deg,55%,35%)",
  blue400: "hsl(210deg,50%,45%)",
  blue500: "hsl(210deg,45%,55%)",
  blue600: "hsl(210deg,50%,65%)",
  blue700: "hsl(207deg,55%,75%)",
  blue800: "hsl(205deg,60%,80%)",
  blue900: "hsl(203deg,70%,85%)",
};

const lengths = {
  small: "4px",
  medium: "8px",
  large: "16px",
  humungous: "64px"
};

We can declare which CSS properties these values are going to apply to by using the defineProperties function:

  • Pass it an object with a properties property.
  • In properties, we declare an object where the keys are the CSS properties the user can set (these need to be valid CSS properties) and the values are the objects we created earlier (our lists of colors and lengths).
// sprinkles.css.ts
import { defineProperties } from "@vanilla-extract/sprinkles";

const colors = {
  blue100: "hsl(210deg,70%,15%)"
  // etc.
}

const lengths = {
  small: "4px",
  // etc.
}

const properties = defineProperties({
  properties: {
    // The keys of this object need to be valid CSS properties
    // The values are the options we provide the user
    color: colors,
    backgroundColor: colors,
    padding: lengths,
  },
});

Then the final step is to pass the return value of defineProperties to the createSprinkles function, and export the returned value:

// sprinkles.css.ts
import { defineProperties, createSprinkles } from "@vanilla-extract/sprinkles";

const colors = {
  blue100: "hsl(210deg,70%,15%)"
  // etc.
}

const lengths = {
  small: "4px",
  // etc. 
}

const properties = defineProperties({
  properties: {
    color: colors,
    // etc. 
  },
});
export const sprinkles = createSprinkles(properties);

Then we can start styling inside our components inline by calling the sprinkles function in the class attribute and choosing which options we want for each element.

// index.ts
import { sprinkles } from "./sprinkles.css";
document.getElementById("root").innerHTML = `<button class="${sprinkles({
  color: "blue200",
  backgroundColor: "blue800",
  padding: "large",
})}">Click me</button>
</div>`;

The JavaScript output holds a class name string for each style property. These class names match a single rule in the output CSS file.

<button class="src_color_blue200__ohrzop1 src_backgroundColor_blue800__ohrzopg src_padding_large__ohrzopk">Click me</button>

As you can see, this API allows you to style elements inside your markup using a set of pre-defined constraints. You also avoid the difficult task of coming up with names of classes for every element. The result is something that feels a lot like Tailwind, but also benefits from all the infrastructure that has been built around TypeScript.

The Sprinkles API also allows you to write conditions and shorthands to create responsive styles using utility classes.

Wrapping up

vanilla-extract feels like a big new step in CSS tooling. A lot of thought has been put into building it into an intuitive, robust solution for styling that utilizes all of the power that static typing provides.

Further reading


The post CSS in TypeScript with vanilla-extract appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.

A Themeable React Data Grid With Great UX-Focused Features

(This is a sponsored post.)

KendoReact can save you boatloads of time because it offers pre-built componentry you can use in your app right away. They look nice, but more importantly, they are easily themeable, so they look however you need them to look. And I’d say the looks aren’t even the important part. There are lots of component libraries out there that focus on the visuals. These components tackle the hardest interactivity problems in UI/UX, and do it with grace, speed, and accessibility in mind.

Let’s take a look at their React Data Grid component.

The ol’ <table> element is the right tool for the job for data grids, but a table doesn’t offer most of the features that make for a good data browsing experience. If we use the KendoReact <Grid /> component (and friends), we get an absolute ton of extra features, any one of which is non-trivial to pull off nicely, and all together make for an extremely compelling solution. Let’s go through a list of what you get.

Sortable Columns

You’ll surely pick a default ordering for your data, but if any given row of data has things like ID’s, dates, or names, it’s perfectly likely that a user would want to sort the column by that data. Perhaps they want to view the oldest orders, or the orders of the highest total value. HTML does not help with ordering in tables, so this is table stakes (get it?!) for a JavaScript library for data grids, and it’s perfectly handled here.

Pagination and Limits

When you have any more than, say, a few dozen rows of data, it’s common that you want to paginate it. That way users don’t have to scroll as much, and equally importantly, it keeps the page fast by not making the DOM too enormous. One of the problems with pagination though is it makes things like sorting harder! You can’t just sort the 20 rows you can see, it is expected that the entire data set gets sorted. Of course that’s handled in KendoReact’s Data Grid component.

Or, if pagination isn’t your thing, the data grid offers virtualized scrolling — in both the column and row directions. That’s a nice touch as the data loads quickly for smooth, natural scrolling.

Expandable Rows

A data grid might have a bunch of data visible across the row itself, but there might be even more data that a user might want to dig out of an entry once they find it. Perhaps it is data that doesn’t need to be cross-referenced in the same way column data is. This can be tricky to pull off, because of the way table cells are laid out. The data is still associated with a single row, but you often need more room than the width of one cell offers. With the KendoReact Data Grid component, you can pass in a detail prop with an arbitrary React component to show when a row is expanded. Super flexible!

Notice how the expanded details can have their own <Grid /> inside!

Responsive Design

Perhaps the most notoriously difficult thing to pull off with <table> designs is how to display them on small screens. Zooming out isn’t very good UX, nor is collapsing the table into something non-table-like. The thing about data grids is that they are all different, and you’ll know data is most important to your users best. The KendoReact Data Grid component helps with this by making your data grid scrollable/swipeable, and also being able to lock columns to make sure they continue to be easy to find and cross-reference.

Filtering Data

This is perhaps my favorite feature just because of how UX-focused it is. Imagine you’re looking at a big data grid of orders, and you’re like “Let me see all orders from White Clover Markets.” With a filtering feature, perhaps you quickly type “clover” into the filter input, and viola, all those orders are right there. That’s extra tricky stuff when you’re also supporting ordering and pagination — so it’s great all these features work together.

Grouping Data

Now this feature actually blows my mind 🤯 a little bit. Filtering and sorting are both very useful, but in some cases, they leave a little bit to be desired. For example, it’s easy to filter too far too quickly, leaving the data you are looking at very limited. And with sorting, you might be trying to look at a subset of data as well, but it’s up to your brain to figure out where that data begins and ends. With grouping, you can tell the data grid to strongly group together things that are the most important to you, but then still leverage filtering and sorting on top of that. It instantly makes your data exploration easier and more useful.

Localization

This is where you can really tell KendoReact went full monty. It would be highly unfortunate to pick some kind of component library and then realize that you need localization and realize it wasn’t made to be a first-class citizen. You avoid all that with KendoReact, which you can see in this Data Grid component. In the demo, you can flip out English for Spanish with a simple dropdown and see all the dates localized. You pull off any sort of translation and localization with the <LocalizationProvider> and <IntlProvider>, both comfortable React concepts.

Exporting to PDF or Excel

Here’s a live demo of this:

C’mon now! That’s very cool.

That’s not all…

Go check out the docs for the React Data Grid. There are a bunch more features we didn’t even get to here (row pinning! cell editing!). And here’s something to ease your mind: this component, and all the KendoReact components, are keyboard friendly and meet Section 508 accessibility standards. That is no small feat. When components are this complex and involve this much interactivity, getting the accessibility right is tough. So not only are you getting good-looking components that work everywhere, you’re getting richly interactive components that deliver UX beyond what you might even think of, and it’s all done fast and accessiblty. That’s pretty unreal, really.


The post A Themeable React Data Grid With Great UX-Focused Features appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.

Scrum: The Obsession with Commitment Matching Velocity

The Obsession With Commitment Matching Velocity

Despite decades-long efforts of the whole agile community—books, blogs, conferences, webinars, videos, meetups, you name it—we are still confronted in many supposedly agile organizations with output-metric driven reporting systems. At the heart of these reporting systems, stuck in the industrial age when the management believed it needed to protect the organization from slacking workers, there is typically a performance metric: velocity.

In the hands of an experienced team, velocity might be useful as a team-internal metric. But, when combined with some managers’ wrong interpretation of commitment, it becomes a tool of oppression. So when did it all go so wrong?

How to Set a Minimum Word Count for WordPress Posts

Do you want to set a word count for your WordPress blog posts?

If you have multiple authors on your site, then setting up a minimum word count can help ensure that writers meet content standards and fully answer the reader’s questions.

In this article, we’ll show you how to set a minimum word count for your WordPress posts.

Set Minimum Word Count for WordPress Posts

Why Set a Minimum Word Count for Your Blog Posts?

Whether you’re creating content yourself or run a multi-author website, you should set certain content standards to ensure top quality articles.

One of the standards you can introduce is a minimum word count for each WordPress blog post. With WordPress, you can restrict authors from publishing blog posts with thin content and ensure high content quality.

Why would you want to enforce longer posts?

Some research suggests that longer content tends to rank significantly better in search results than short content, which could help you get more traffic to your blog.

That being said, let’s look at how you can set a minimum word count in a WordPress blog.

Method 1: Set a Minimum Word Count Using a Plugin

A simple way to add a minimum word count to your WordPress website is by using a plugin like PublishPress Checklists.

PublishPress Checklists allow you to set tasks that authors must complete before publishing content. This includes adding a minimum and maximum word count on posts and pages.

For this tutorial, you can use the free version of PublishPress Checklists, since it has the features we need. There’s also a premium version available that offers more features like checklists for WooCommerce products.

First, you’ll need to install and activate the PublishPress Checklists plugin. You can follow our step-by-step tutorial on how to install a WordPress plugin for more details.

Upon activation, you’ll need to go to Checklists from your WordPress admin panel. Next, you can set minimum and maximum words for the ‘Number of words in content’ option.

Change PublishPress Checklists settings

After that, you can choose whether you want to make the ‘Number of words in content’ option to be disabled, required, or recommended task from the dropdown menu.

If you select Recommended, then authors can publish articles even if they don’t meet the minimum word count. However, the Required option makes it mandatory to complete the word count task, so go ahead and select the Required option.

Besides that, PublishPress Checklists also lets you add user roles to exclude from meeting the word count requirement. Simply click on the box under the ‘Who can ignore the task’ column and select a user role.

Choose user roles to exclude

When you’ve set the number of words writers should complete, simply scroll down and click the ‘Save Changes’ button.

Save your changes

Now you can go to Posts » Add New to create a new blog post and see the minimum word count requirement in action.

If the post doesn’t contain the minimum number of words, a warning icon will appear on the ‘Publish’ button in the WordPress editor. The plugin will also show that the word count task wasn’t met in the ‘Checklist’ settings box on your right.

Minimum word count warning in editor

Once your content meets the minimum word count, the checklist task will show a green checkmark, and authors can publish the blog post.

Green checkmark when the checklist task is met

Method 2: Manually Set a Minimum Word Count Limit

Another way to add a minimum word count on your WordPress website is by adding a code snippet to the functions.php files in a WordPress theme.

However, we don’t recommend editing your site’s theme files. That’s because even a small mistake can break your website and even prevent you from accessing the WordPress dashboard.

An easier way to add code to your site is by using the Code Snippets plugin. It lets you add custom code without worrying about breaking your site. Plus, it makes it easier to keep track of any snippets you add to your site.

First, you’ll need to install and activate the Code Snippets plugin. If you need help, then check out our guide on how to install a WordPress plugin.

Once the plugin is active, simply head over to Snippets » Add New from your WordPress dashboard. You can start by adding a title for your custom code.

Add new code snippet

Now, you’ll need to copy the following code:

function minWord($content)
{
	global $post;
	$content = $post->post_content;
	if (str_word_count($content) < 100 ) //set this to the minimum number of words
	wp_die( __('Error: your post is below the minimum word count. It needs to be longer than 100 words.') );
}
add_action('publish_post', 'minWord');

Note: You may change the minimum number of words from 100 to whatever you like and also customize the error to make it helpful. Make sure to change the number in both places in the code snippets.

Next, simply paste the copied code in your new snippet under the ‘Code’ area and then click the ‘Save Changes’ and ‘Activate’ buttons.

Save and activate your custom code

Now, if you try to publish a blog post that’s below the word count limit (100 words in our example), then you’ll see a publishing error.

Publishing error for not meeting word count

We hope this article helped you learn how to set a minimum word count for a WordPress blog. You may also want to look at how to create an email newsletter the right way, or see our expert pick of the best HR payroll software for small business.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Set a Minimum Word Count for WordPress Posts appeared first on WPBeginner.

Collective #682






Collective 682 item image

Atropos

Atropos is a lightweight, free and open-source JavaScript library to create touch-friendly 3D parallax hover effects.

Check it out











Collective 682 item image

Tidy Viewer

Tidy Viewer is a cross-platform CLI CSV pretty printer that uses column styling to maximize viewer enjoyment.

Check it out



Collective 682 item image

AESON

Welcome to AESON, a futuristic (and creepy) chatroom in WebGL. The project was made at Gobelins Paris during a workshop. By Thoma Lecornu. Read more about it in this tweet.

Check it out


Collective 682 item image

Medusa

In case you didn’t know about it: Medusa is a headless open-source commerce platform.

Check it out




Collective 682 item image

From Our Blog

Creating 3D Characters in Three.js

Are you looking to get started with 3D on the web? In this tutorial we’ll walk through creating a three-dimensional character using Three.js, adding some simple but effective animation, and a generative color palette.

Read it


The post Collective #682 appeared first on Codrops.

Leveraging Salesforce Using a Client Written In Angular

In the “Leveraging Salesforce Without Using Spring Boot” article, I navigated the course for introducing a Spring Boot service that would leverage the well-established Salesforce RESTful API. The goal of this service was to act as a middleware layer; that way, clients not written in Salesforce could retrieve and update contact data stored in Salesforce. This backend service implemented its own caching layer to provide a faster response time and also cut down on the number of times Salesforce needed to be called.

In “Leveraging Salesforce Using a Client Written In Svelte,” I introduced a simple client written in Svelte, which made it possible to update the Salesforce data using an inline editor—again, without actually using the Salesforce client.