UNIT 18 • STAGE 3 OF 7
New pattern: filterable legislation cards by decade. New CSS: grid-column 1 / -1.
Stage 3 introduces the most used interactive pattern in web development: a grid of items that a user can filter by category. You click a button, and only the matching items appear. Everything else hides. The same pattern powers product catalogs, search results, portfolio galleries, and content dashboards across professional web development.
In this unit, the items are laws. The categories are decades: 1970s, 1980s, 1990s. Each law card carries a data-decade attribute. Each filter button carries a data-filter attribute. The JavaScript reads the button's filter value and compares it to each card's decade. If they match, the card shows. If they do not, the card hides.
This section also introduces a second new CSS concept: grid-column: 1 / -1, which makes any element span all columns in a grid. You will use it on the California v. Cabazon Band callout card.
User clicks "1980s" button → JS reads this.dataset.filter = "1980s" → JS loops through every .law-card and .cabazon-callout → checks card.dataset.decade → if it equals "1980s" or filter is "all", set card.style.display = "block" → otherwise set card.style.display = "none".
The filter buttons sit in a .filter-row flex container above the grid. Each button starts with background: transparent and a subtle border. When a button becomes active (the selected filter), it fills with the accent color. The first button starts with the active class already applied in HTML, showing "All Laws" as the default.
The California v. Cabazon Band callout is more important than a single law card. It needs to span the full width of the grid to signal that. grid-column: 1 / -1 does this in one line. The -1 is a negative grid line index: it means "the last grid line," regardless of how many columns the grid has.
You will use grid-column: 1 / -1 again in Stages 4 and 5 on different grids. Once you know it, you will use it constantly.
The Cabazon Band and Morongo Band of Mission Indians in California operated high-stakes bingo and card games on reservation lands. California tried to regulate or shut the games down. The Supreme Court ruled 6-3 that if a state permits a form of gaming, even with regulation, it cannot use state law to prohibit Tribes from offering that same gaming on Tribal lands. The key distinction: if a state prohibits an activity entirely, it may have authority to apply that prohibition on Tribal land. If a state only regulates the activity, it cannot impose that regulatory framework on Tribes. California allowed bingo. It could not prohibit Tribal bingo. Congress responded the next year with IGRA, creating the legal structure for Tribal gaming that exists today.
Each law card has a decade tag, the law's full name, its acronym or public law number, and a short description of what it did. The data-decade attribute on each card is what the JavaScript reads to decide whether to show or hide it.
The filter runs three operations on each button click: (1) remove .active from all buttons, (2) add .active to the clicked button, (3) loop through all cards and show or hide based on the selected filter.
You have built the filterable legislation grid. Click each filter button in the preview and verify that the right cards appear and disappear. Test the "All Laws" button to confirm everything comes back. Stage 4 adds the nation profiles: Mille Lacs Band, Red Lake Nation, and Pine Ridge.