Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move custom tw- helpers to tailwind plugin #31184

Merged
merged 3 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {readFileSync} from 'node:fs';
import {env} from 'node:process';
import {parse} from 'postcss';
import plugin from 'tailwindcss/plugin.js';

const isProduction = env.NODE_ENV !== 'development';

Expand Down Expand Up @@ -98,4 +99,26 @@ export default {
})),
},
},
plugins: [
plugin(({addUtilities}) => {
addUtilities({
// tw-hidden must win all other "display: xxx !important" classes to get the chance to "hide" an element.
// do not use:
// * "[hidden]" attribute: it's too weak, can not be applied to an element with "display: flex"
// * ".hidden" class: it has been polluted by Fomantic UI in many cases
// * inline style="display: none": it's difficult to tweak
// * jQuery's show/hide/toggle: it can not show/hide elements with "display: xxx !important"
// only use:
// * this ".tw-hidden" class
// * showElem/hideElem/toggleElem functions in "utils/dom.js"
'.hidden.hidden': {
'display': 'none',
},
// proposed class from https://github.com/tailwindlabs/tailwindcss/pull/12128
'.break-anywhere': {
'overflow-wrap': 'anywhere',
},
});
}),
],
};
16 changes: 0 additions & 16 deletions web_src/css/helpers.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,6 @@ Gitea's private styles use `g-` prefix.
.interact-bg:hover { background: var(--color-hover) !important; }
.interact-bg:active { background: var(--color-active) !important; }

/*
tw-hidden must win all other "display: xxx !important" classes to get the chance to "hide" an element.
do not use:
* "[hidden]" attribute: it's too weak, can not be applied to an element with "display: flex"
* ".hidden" class: it has been polluted by Fomantic UI in many cases
* inline style="display: none": it's difficult to tweak
* jQuery's show/hide/toggle: it can not show/hide elements with "display: xxx !important"
only use:
* this ".tw-hidden" class
* showElem/hideElem/toggleElem functions in "utils/dom.js"
*/
.tw-hidden.tw-hidden { display: none !important; }

/* proposed class from https://github.com/tailwindlabs/tailwindcss/pull/12128 */
.tw-break-anywhere { overflow-wrap: anywhere !important; }

@media (max-width: 767.98px) {
/* double selector so it wins over .tw-flex (old .gt-df) etc */
.not-mobile.not-mobile {
Expand Down