Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Safelist the classes for common icon sizes (#452)

Olga Bulatc953aac489ab
diff --git a/src/components/VIcon/VIcon.vue b/src/components/VIcon/VIcon.vue
index 1d146c3b7..1064cbb5b 100644
--- a/src/components/VIcon/VIcon.vue
+++ b/src/components/VIcon/VIcon.vue
@@ -44,6 +44,17 @@ export default {
type: String,
default: 'icon',
},
+ /**
+ * The size of the icon based on tailwind values. Possible values:
+ * 4 - 1rem, 5 - 1.25rem, 6 - 1.5rem.
+ *
+ * @default 6
+ */
+ size: {
+ type: Number,
+ default: 6,
+ validator: (val) => [4, 5, 6].includes(val),
+ },
/**
* whether to flip the icon for RTL languages; This generally makes sense
* for directional icons such as those involving arrows.
@@ -52,14 +63,6 @@ export default {
type: Boolean,
default: false,
},
- /**
- * the size of the icon in terms of the Tailwind height and width scale; The
- * icon, being square, uses this for both dimensions.
- */
- size: {
- type: Number,
- default: 6,
- },
},
}
</script>
diff --git a/tailwind.config.js b/tailwind.config.js
index bb45259e8..933a9ba87 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -1,5 +1,14 @@
module.exports = {
- purge: ['src/**/*.{vue,js,jsx,ts,tsx,mdx}', './nuxt.config.js'],
+ purge: {
+ content: ['src/**/*.{vue,js,jsx,ts,tsx,mdx}', './nuxt.config.js'],
+ /**
+ * In production, dynamically-created class names are purged as unused:
+ * https://tailwindcss.com/docs/optimizing-for-production#writing-purgeable-html
+ * The commonly-used icon size classes are safe-listed here
+ * to ensure that they are not removed:
+ */
+ safelist: ['w-4', 'w-5', 'w-6', 'h-4', 'h-5', 'h-6'],
+ },
theme: {
colors: {
// Accents