-
Notifications
You must be signed in to change notification settings - Fork 2
Feat - Add card clues to narrow down the card #116
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
Closed
+136
−3
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
cd2dfff
Change model in `ScryfallCard` to have cmc, set_name, and oracle_text
daryllxd 5e56ef6
Add `CardClues` component
daryllxd 7175907
Fix z-index issue with Autocomplete and clues
daryllxd b98dabc
Dismiss the clue when the card changes
daryllxd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| <script setup lang="ts"> | ||
| import { computed, ref, watch } from "vue"; | ||
| import type { ScryfallCard } from "../models/scryfall-card"; | ||
| import { useAppSelector } from "../store"; | ||
|
|
||
| const props = defineProps<{ | ||
| card: ScryfallCard; | ||
| }>(); | ||
|
|
||
| const activeClue = ref<"cmc" | "set" | "type" | "oracle" | null>(null); | ||
| const storeCard = useAppSelector((state) => state.game.card); | ||
|
|
||
| // Dismiss the active clue when the card changes | ||
| watch(storeCard, () => { | ||
| activeClue.value = null; | ||
| }); | ||
|
|
||
| const clues = [ | ||
| { | ||
| id: "cmc", | ||
| label: "Show Mana Value", | ||
| }, | ||
| { | ||
| id: "set", | ||
| label: "Show Set", | ||
| }, | ||
| { | ||
| id: "type", | ||
| label: "Show Type", | ||
| }, | ||
| { | ||
| id: "oracle", | ||
| label: "Show Rules Text", | ||
| }, | ||
| ] as const; | ||
|
|
||
| const visibleClues = computed(() => | ||
| clues.filter((clue) => clue.id === "type" || clue.id === "oracle" || !props.card.card_faces) | ||
| ); | ||
| </script> | ||
|
|
||
| <template> | ||
| <div class="clue-buttons"> | ||
| <button | ||
| v-for="clue in visibleClues" | ||
| :key="clue.id" | ||
| class="clue-button" | ||
| @click="activeClue = activeClue === clue.id ? null : clue.id" | ||
| :class="{ active: activeClue === clue.id }" | ||
| > | ||
| {{ clue.label }} | ||
| </button> | ||
| </div> | ||
|
|
||
| <div v-if="activeClue" class="clues"> | ||
| <div v-if="activeClue === 'cmc' && !card.card_faces" class="clue"> | ||
| Mana Value: {{ card.cmc }} | ||
| </div> | ||
| <div v-if="activeClue === 'set' && !card.card_faces" class="clue">Set: {{ card.set_name }}</div> | ||
| <div v-if="activeClue === 'type'" class="clue">Type: {{ card.type_line }}</div> | ||
| <div v-if="activeClue === 'oracle'" class="clue oracle-text"> | ||
| {{ card.oracle_text }} | ||
| </div> | ||
| </div> | ||
| </template> | ||
|
|
||
| <style scoped lang="scss"> | ||
| .clue-buttons { | ||
| display: flex; | ||
| gap: 8px; | ||
| margin: 16px 0; | ||
| flex-wrap: wrap; | ||
| justify-content: center; | ||
| } | ||
|
|
||
| .clue-button { | ||
| padding: 8px 16px; | ||
| background: var(--clue-button-background, #4a5568); | ||
| color: white; | ||
| border: none; | ||
| border-radius: 4px; | ||
| cursor: pointer; | ||
| font-size: 1em; | ||
| transition: all 0.2s; | ||
|
|
||
| &:hover { | ||
| background: var(--clue-button-hover-background, #2d3748); | ||
| } | ||
|
|
||
| &:focus { | ||
| outline: 2px solid var(--clue-button-focus-outline, #4299e1); | ||
| outline-offset: 2px; | ||
| } | ||
|
|
||
| &.active { | ||
| background: var(--clue-button-active-background, #2d3748); | ||
| transform: translateY(1px); | ||
| } | ||
| } | ||
|
|
||
| .clues { | ||
| margin: 16px 0; | ||
| padding: 16px; | ||
| border-radius: 8px; | ||
| text-align: center; | ||
| width: 100%; | ||
| max-width: 400px; | ||
| animation: slideDown 0.2s ease-out; | ||
| } | ||
|
|
||
| .clue { | ||
| font-size: 1.1em; | ||
| font-weight: 500; | ||
| } | ||
|
|
||
| .oracle-text { | ||
| white-space: pre-line; | ||
| text-align: left; | ||
| line-height: 1.5; | ||
| } | ||
| </style> |
This file contains hidden or 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 file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,6 +66,7 @@ const vScrollIntoView: Directive<HTMLElement, boolean> = { | |
| align-items: stretch; | ||
| max-height: calc((var(--count) + 0.6) * (1em + var(--v-padding) * 2)); | ||
| overflow-y: scroll; | ||
| z-index: 10; | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| @include mixins.bp-large { | ||
| --count: 4; | ||
|
|
||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,9 @@ export type DefaultScryfallCard = { | |
| set: string; | ||
| image_uris: ScryfallImageUris; | ||
| card_faces?: never; | ||
| cmc: number; | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is duplicated for now and I notice this exists https://github.com/scryfall/api-types, checking if this can be in another PR or in this one? |
||
| set_name: string; | ||
| oracle_text: string; | ||
| }; | ||
|
|
||
| export type SplitScryfallCard = { | ||
|
|
@@ -46,6 +49,9 @@ export type SplitScryfallCard = { | |
| set: string; | ||
| image_uris: ScryfallImageUris; | ||
| card_faces: ScryfallSplitCardFace[]; | ||
| cmc: number; | ||
| set_name: string; | ||
| oracle_text: string; | ||
| }; | ||
|
|
||
| export type DfcScryfallCard = { | ||
|
|
@@ -59,6 +65,9 @@ export type DfcScryfallCard = { | |
| card_faces: ScryfallCardFace[]; | ||
| image_uris?: never; | ||
| flavor_name?: never; | ||
| cmc: number; | ||
| set_name: string; | ||
| oracle_text: string; | ||
| }; | ||
|
|
||
| export type ScryfallCard = DefaultScryfallCard | SplitScryfallCard | DfcScryfallCard; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, maybe my linter is not set up correctly (I am using Cursor)