-
When writing a string of multiple utility classes, always do so in an order with meaning. The "Concentric CSS" approach works well with utility classes (i.e,. 1. positioning/visibility 2. box model 3. borders 4. backgrounds 5. typography 6. other visual adjustments). Once you establish a familiar pattern of ordering, parsing through long strings of utility classes will become much, much faster so a little more effort up front goes a long way!
-
Always use fewer utility classes when possible. For example, use
mx-2
instead ofml-2 mr-2
and don't be afraid to use the simplerp-4 lg:pt-8
instead of the longer, more complicatedpt-4 lg:pt-8 pr-4 pb-4 pl-4
. -
Prefix all utility classes that will only apply at a certain breakpoint with that breakpoint's prefix. For example, use
block lg:flex lg:flex-col lg:justify-center
instead ofblock lg:flex flex-col justify-center
to make it very clear that the flexbox utilities are only applicable at the
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This code shows how to resolve collisions using Matter physics with Phaser 3 in constant O(1) time. | |
Going through all the collision pairs is still linear O(n) time depending on how many collisions happened this frame | |
but the code that handles the resolution of the collision is constant and will not change with the total number of CollisionCategories / collision-lookups. | |
The way the code works is by generating a number based on the each of the collision combinations, use that number as a key for storing a pointer to the respective collision handler function, | |
and then when a collision happens, calculate the number again of both bodies' collision categories and use that number to fetch the collision handler function. Simple. | |
// dreasgrech - https://github.com/dreasgrech/ | |
// TS example - Jelleebeen - https://github.com/jelleebeen/ | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const ScrollTopArrowComponent = () => { | |
// Track whether the scroll arrow is needed. | |
const [showScroll, setShowScroll] = useState(null); | |
// Check the scroll state, re-memoize when scroll state changes. | |
const checkScrollTop = useCallback( | |
() => { | |
const headerHeight = 400; | |
if (!showScroll && window.pageYOffset > headerHeight) { | |
setShowScroll(true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ; | |
import openfl.display.Sprite; | |
/** | |
* ... | |
* @author Kenton Hamaluik | |
*/ | |
class AABB | |
{ | |
public var center:Vector = new Vector(); |