diff --git a/components/CharacterGrid/index.tsx b/components/CharacterGrid/index.tsx index f74d6e0b..48cc0ca8 100644 --- a/components/CharacterGrid/index.tsx +++ b/components/CharacterGrid/index.tsx @@ -11,7 +11,7 @@ import JobSection from '~components/JobSection' import CharacterUnit from '~components/CharacterUnit' import CharacterConflictModal from '~components/CharacterConflictModal' -import type { JobSkillObject, SearchableObject } from '~types' +import type { DetailsObject, JobSkillObject, SearchableObject } from '~types' import api from '~utils/api' import { appState } from '~utils/appState' @@ -23,7 +23,7 @@ import './index.scss' interface Props { new: boolean characters?: GridCharacter[] - createParty: () => Promise> + createParty: (details?: DetailsObject) => Promise pushHistory?: (path: string) => void } @@ -95,13 +95,8 @@ const CharacterGrid = (props: Props) => { const character = object as Character if (!party.id) { - props.createParty().then((response) => { - const party = response.data.party - appState.party.id = party.id - setSlug(party.shortcode) - - if (props.pushHistory) props.pushHistory(`/p/${party.shortcode}`) - saveCharacter(party.id, character, position) + props.createParty().then((team) => { + saveCharacter(team.id, character, position) .then((response) => storeGridCharacter(response.data)) .catch((error) => console.error(error)) }) @@ -184,19 +179,24 @@ const CharacterGrid = (props: Props) => { }, } - if (party.id && appState.party.editable) { + if (!party.id) { + // If the party has no ID, create a new party + await props.createParty() + } + + if (appState.party.id) { const response = await api.updateJob({ - partyId: party.id, + partyId: appState.party.id, params: payload, }) - const newParty = response.data + const team = response.data - setJob(newParty.job) - appState.party.job = newParty.job + setJob(team.job) + appState.party.job = team.job - setJobSkills(newParty.job_skills) - appState.party.jobSkills = newParty.job_skills + setJobSkills(team.job_skills) + appState.party.jobSkills = team.job_skills } } diff --git a/components/LabelledInput/index.tsx b/components/LabelledInput/index.tsx index 19931805..57a6b837 100644 --- a/components/LabelledInput/index.tsx +++ b/components/LabelledInput/index.tsx @@ -26,7 +26,7 @@ const LabelledInput = React.forwardRef(function Input( // Classes const classes = classNames({ Input: true }, props.className) - const { defaultValue, ...inputProps } = props + const { defaultValue, visible, ...inputProps } = props // Change value when prop updates useEffect(() => { diff --git a/components/Party/index.tsx b/components/Party/index.tsx index 3cd98d4b..14c3f49a 100644 --- a/components/Party/index.tsx +++ b/components/Party/index.tsx @@ -11,7 +11,7 @@ import CharacterGrid from '~components/CharacterGrid' import api from '~utils/api' import { appState, initialAppState } from '~utils/appState' -import { GridType, TeamElement } from '~utils/enums' +import { GridType } from '~utils/enums' import type { DetailsObject } from '~types' import './index.scss' @@ -40,63 +40,59 @@ const Party = (props: Props) => { }, []) // Methods: Creating a new party - async function createParty(extra: boolean = false) { - return await api.endpoints.parties.create({ - party: { - extra: extra, - }, - }) + async function createParty(details?: DetailsObject) { + let payload = {} + if (details) payload = formatDetailsObject(details) + + return await api.endpoints.parties + .create(payload) + .then((response) => storeParty(response.data.party)) } // Methods: Updating the party's details - function checkboxChanged(event: React.ChangeEvent) { - appState.party.extra = event.target.checked + async function updateDetails(details: DetailsObject) { + if (!appState.party.id) return await createParty(details) + else updateParty(details) + } - if (party.id) { - api.endpoints.parties.update(party.id, { - party: { extra: event.target.checked }, - }) + function formatDetailsObject(details: DetailsObject) { + const payload: { [key: string]: any } = {} + + if (details.name) payload.name = details.name + if (details.description) payload.description = details.description + if (details.raid) payload.raid_id = details.raid.id + if (details.chargeAttack) payload.charge_attack = details.chargeAttack + if (details.fullAuto) payload.full_auto = details.fullAuto + if (details.autoGuard) payload.auto_guard = details.autoGuard + if (details.clearTime) payload.clear_time = details.clearTime + if (details.buttonCount) payload.button_count = details.buttonCount + if (details.chainCount) payload.chain_count = details.chainCount + if (details.turnCount) payload.turn_count = details.turnCount + if (details.extra) payload.extra = details.extra + if (details.job) payload.job_id = details.job.id + + if (Object.keys(payload).length > 1) return { party: payload } + else return {} + } + + async function updateParty(details: DetailsObject) { + const payload = formatDetailsObject(details) + + if (appState.party.id) { + return await api.endpoints.parties + .update(appState.party.id, payload) + .then((response) => storeParty(response.data.party)) } } - function updateDetails(details: DetailsObject) { - if ( - appState.party.name !== details.name || - appState.party.description !== details.description || - appState.party.raid?.id !== details.raid?.id - ) { - if (appState.party.id) - api.endpoints.parties - .update(appState.party.id, { - party: { - name: details.name, - description: details.description, - raid_id: details.raid?.id, - charge_attack: details.chargeAttack, - full_auto: details.fullAuto, - auto_guard: details.autoGuard, - clear_time: details.clearTime, - button_count: details.buttonCount, - chain_count: details.chainCount, - turn_count: details.turnCount, - }, - }) - .then(() => { - appState.party.name = details.name - appState.party.description = details.description - appState.party.raid = details.raid + function checkboxChanged(event: React.ChangeEvent) { + appState.party.extra = event.target.checked - appState.party.chargeAttack = details.chargeAttack - appState.party.fullAuto = details.fullAuto - appState.party.autoGuard = details.autoGuard - - appState.party.clearTime = details.clearTime - appState.party.buttonCount = details.buttonCount - appState.party.chainCount = details.chainCount - appState.party.turnCount = details.turnCount - - appState.party.updated_at = party.updated_at - }) + // Only save if this is a saved party + if (appState.party.id) { + api.endpoints.parties.update(appState.party.id, { + party: { extra: event.target.checked }, + }) } } @@ -126,7 +122,7 @@ const Party = (props: Props) => { // Methods: Storing party data const storeParty = function (team: Party) { - // Store the important party and state-keeping values + // Store the important party and state-keeping values in global state appState.party.name = team.name appState.party.description = team.description appState.party.raid = team.raid @@ -147,6 +143,11 @@ const Party = (props: Props) => { storeCharacters(team.characters) storeWeapons(team.weapons) storeSummons(team.summons) + + // Then, push the browser history to the new party's URL + if (props.pushHistory) props.pushHistory(`/p/${team.shortcode}`) + + return team } const storeCharacters = (list: Array) => { diff --git a/components/PartyDetails/index.tsx b/components/PartyDetails/index.tsx index 770ded74..ffc3f99e 100644 --- a/components/PartyDetails/index.tsx +++ b/components/PartyDetails/index.tsx @@ -252,11 +252,14 @@ const PartyDetails = (props: Props) => { } function toggleDetails() { - if (name !== party.name) { - const resetName = party.name ? party.name : 'Untitled' - setName(resetName) - if (nameInput.current) nameInput.current.value = resetName - } + // Enabling this code will make live updates not work, + // but I'm not sure why it's here, so we're not going to remove it. + + // if (name !== party.name) { + // const resetName = party.name ? party.name : '' + // setName(resetName) + // if (nameInput.current) nameInput.current.value = resetName + // } setOpen(!open) } @@ -270,7 +273,6 @@ const PartyDetails = (props: Props) => { } function updateDetails(event: React.MouseEvent) { - const nameValue = nameInput.current?.value const descriptionValue = descriptionInput.current?.value const raid = raids.find((raid) => raid.slug === raidSlug) @@ -282,7 +284,7 @@ const PartyDetails = (props: Props) => { buttonCount: buttonCount, turnCount: turnCount, chainCount: chainCount, - name: nameValue, + name: name, description: descriptionValue, raid: raid, } diff --git a/components/RoadmapModal/index.scss b/components/RoadmapModal/index.scss index 06f83b3e..7fc37b7b 100644 --- a/components/RoadmapModal/index.scss +++ b/components/RoadmapModal/index.scss @@ -1,26 +1,115 @@ -h3.priority { - font-weight: $medium; - font-size: $font-medium; - margin-bottom: $unit; +.Roadmap.Dialog { + max-height: 60vh; + overflow-y: scroll; - &.high { - color: $red; + .top { + display: flex; + flex-direction: column; + gap: $unit; + + h3.priority { + font-weight: $medium; + font-size: $font-large; + + &.in_progress { + color: $yellow; + } + + &.high { + color: $red; + } + + &.mid { + color: $orange-10; + } + + &.low { + color: $blue; + } + } + + p { + margin-bottom: $unit; + } + + .LinkItem { + $diameter: $unit-6x; + border: 1px solid var(--link-item-bg); + border-radius: $card-corner; + + &:hover { + background-color: var(--link-item-bg); + + svg { + fill: var(--link-item-image-color-hover); + } + } + + a { + display: flex; + padding: $unit-2x; + + &:hover { + text-decoration: none; + } + + .Left { + align-items: center; + display: flex; + gap: $unit-2x; + flex-grow: 1; + } + + svg { + fill: var(--link-item-image-color); + width: $diameter; + height: auto; + + &.ShareIcon { + width: $unit-4x; + } + } + } + + h3 { + font-weight: $bold; + max-width: 70%; + line-height: 1.3; + } + } } - &.mid { - color: $orange-10; + .Separator { + background: var(--separator-bg); + border-radius: 2px; + margin: $unit-3x 0; + height: 2px; + } + p { + color: var(--text-secondary); + + font-size: $font-regular; + line-height: 1.3; } - &.low { - color: $blue; - } -} - -.notes { - color: var(--text-primary); - list-style-type: disc; - - li { - margin-bottom: $unit-half; + .notes { + color: var(--text-primary); + list-style-type: none; + + li { + display: flex; + flex-direction: column; + gap: $unit; + margin-bottom: $unit-2x; + + h4 { + font-size: $font-medium; + font-weight: $bold; + } + + p { + font-size: $font-regular; + } + } } } diff --git a/components/RoadmapModal/index.tsx b/components/RoadmapModal/index.tsx index 8f379245..feba1991 100644 --- a/components/RoadmapModal/index.tsx +++ b/components/RoadmapModal/index.tsx @@ -5,13 +5,12 @@ import * as Dialog from '@radix-ui/react-dialog' import CrossIcon from '~public/icons/Cross.svg' import ShareIcon from '~public/icons/Share.svg' -import DiscordIcon from '~public/icons/discord.svg' import GithubIcon from '~public/icons/github.svg' import './index.scss' const RoadmapModal = () => { - const { t } = useTranslation('common') + const { t } = useTranslation('roadmap') return ( @@ -22,13 +21,11 @@ const RoadmapModal = () => { event.preventDefault()} >
- - {t('menu.roadmap')} - + {t('title')} @@ -37,37 +34,52 @@ const RoadmapModal = () => {
-

High priority

+
+

{t('subtitle')}

+

{t('blurb')}

+

{t('link.intro')}

+ +
+
    -
  • URL state for team tabs
  • - More team details (Full Auto, Auto Guard, Clear Time) and - filters +

    {t('roadmap.item1.title')}

    +

    {t('roadmap.item1.description')}

  • - Character mods - Rings, Earrings, Perpetuity Rings, Styles +

    {t('roadmap.item2.title')}

    +

    {t('roadmap.item2.description')}

    +
  • +
  • +

    {t('roadmap.item3.title')}

    +

    {t('roadmap.item3.description')}

    +
  • +
  • +

    {t('roadmap.item4.title')}

    +

    {t('roadmap.item4.description')}

    +
  • +
  • +

    {t('roadmap.item5.title')}

    +

    {t('roadmap.item5.description')}

    +
  • +
  • +

    {t('roadmap.item6.title')}

    +

    {t('roadmap.item6.description')}

  • -
-
-
-

Medium priority

-
    -
  • Dark mode improvements for logged out users
  • -
  • Light Markdown in team details
  • -
  • Transcendence Steps - Eternals and Bahamut
  • -
  • Rearrange items in team
  • -
  • Remove items from team
  • -
-
-
-

Low priority

-
    -
  • Figure out DNS to simplify URLs to just granblue.team
  • -
  • Unify About, Changelog, Roadmap
  • -
  • Add R characters
  • -
  • Add images for weird units like Aquors
  • -
  • Character substitutions
  • -
  • Deeper gbf.wiki integration
diff --git a/components/SummonGrid/index.tsx b/components/SummonGrid/index.tsx index 820eba24..de1847bb 100644 --- a/components/SummonGrid/index.tsx +++ b/components/SummonGrid/index.tsx @@ -13,7 +13,7 @@ import ExtraSummons from '~components/ExtraSummons' import api from '~utils/api' import { appState } from '~utils/appState' import { accountState } from '~utils/accountState' -import type { SearchableObject } from '~types' +import type { DetailsObject, SearchableObject } from '~types' import './index.scss' @@ -21,7 +21,7 @@ import './index.scss' interface Props { new: boolean summons?: GridSummon[] - createParty: () => Promise> + createParty: (details?: DetailsObject) => Promise pushHistory?: (path: string) => void } @@ -86,14 +86,8 @@ const SummonGrid = (props: Props) => { const summon = object as Summon if (!party.id) { - props.createParty().then((response) => { - const party = response.data.party - appState.party.id = party.id - setSlug(party.shortcode) - - if (props.pushHistory) props.pushHistory(`/p/${party.shortcode}`) - - saveSummon(party.id, summon, position).then((response) => + props.createParty().then((team) => { + saveSummon(team.id, summon, position).then((response) => storeGridSummon(response.data) ) }) diff --git a/components/WeaponGrid/index.tsx b/components/WeaponGrid/index.tsx index 59361cfa..f9312a5d 100644 --- a/components/WeaponGrid/index.tsx +++ b/components/WeaponGrid/index.tsx @@ -13,7 +13,7 @@ import ExtraWeapons from '~components/ExtraWeapons' import api from '~utils/api' import { appState } from '~utils/appState' -import type { SearchableObject } from '~types' +import type { DetailsObject, SearchableObject } from '~types' import './index.scss' import WeaponConflictModal from '~components/WeaponConflictModal' @@ -24,7 +24,7 @@ import { accountState } from '~utils/accountState' interface Props { new: boolean weapons?: GridWeapon[] - createParty: (extra: boolean) => Promise> + createParty: (details: DetailsObject) => Promise pushHistory?: (path: string) => void } @@ -89,16 +89,11 @@ const WeaponGrid = (props: Props) => { if (position == 1) appState.party.element = weapon.element if (!party.id) { - props.createParty(party.extra).then((response) => { - const party = response.data.party - appState.party.id = party.id - setSlug(party.shortcode) - - if (props.pushHistory) props.pushHistory(`/p/${party.shortcode}`) - - saveWeapon(party.id, weapon, position).then((response) => + const payload: DetailsObject = { extra: party.extra } + props.createParty(payload).then((team) => { + saveWeapon(team.id, weapon, position).then((response) => { storeGridWeapon(response.data.grid_weapon) - ) + }) }) } else { if (party.editable) diff --git a/pages/[username].tsx b/pages/[username].tsx index 6cd090a1..805d3acb 100644 --- a/pages/[username].tsx +++ b/pages/[username].tsx @@ -391,7 +391,7 @@ export const getServerSideProps = async ({ req, res, locale, query }: { req: Nex meta: meta, raids: raids, sortedRaids: sortedRaids, - ...(await serverSideTranslations(locale, ['common'])), + ...(await serverSideTranslations(locale, ['common', 'roadmap'])), // Will be passed to the page component as props }, } diff --git a/pages/new/index.tsx b/pages/new/index.tsx index ff174d2e..d3f3881b 100644 --- a/pages/new/index.tsx +++ b/pages/new/index.tsx @@ -105,7 +105,7 @@ export const getServerSideProps = async ({ req, res, locale, query }: { req: Nex raids: raids, sortedRaids: sortedRaids, weaponKeys: weaponKeys, - ...(await serverSideTranslations(locale, ['common'])), + ...(await serverSideTranslations(locale, ['common', 'roadmap'])), // Will be passed to the page component as props }, } diff --git a/pages/p/[party].tsx b/pages/p/[party].tsx index bd5b736a..7e1631ca 100644 --- a/pages/p/[party].tsx +++ b/pages/p/[party].tsx @@ -190,9 +190,9 @@ export const getServerSideProps = async ({ req, res, locale, query }: { req: Nex sortedRaids: sortedRaids, weaponKeys: weaponKeys, meta: { - element: elementEmoji() + element: elementEmoji(), }, - ...(await serverSideTranslations(locale, ['common'])), + ...(await serverSideTranslations(locale, ['common', 'roadmap'])), // Will be passed to the page component as props }, } diff --git a/pages/saved.tsx b/pages/saved.tsx index 68ce09dd..b6bd1aba 100644 --- a/pages/saved.tsx +++ b/pages/saved.tsx @@ -382,7 +382,7 @@ export const getServerSideProps = async ({ req, res, locale, query }: { req: Nex meta: meta, raids: raids, sortedRaids: sortedRaids, - ...(await serverSideTranslations(locale, ['common'])), + ...(await serverSideTranslations(locale, ['common', 'roadmap'])), // Will be passed to the page component as props }, } diff --git a/pages/teams.tsx b/pages/teams.tsx index a75f7ad8..03502514 100644 --- a/pages/teams.tsx +++ b/pages/teams.tsx @@ -393,7 +393,7 @@ export const getServerSideProps = async ({ req, res, locale, query }: { req: Nex meta: meta, raids: raids, sortedRaids: sortedRaids, - ...(await serverSideTranslations(locale, ['common'])), + ...(await serverSideTranslations(locale, ['common', 'roadmap'])), // Will be passed to the page component as props }, } diff --git a/public/locales/en/roadmap.json b/public/locales/en/roadmap.json new file mode 100644 index 00000000..c5482c86 --- /dev/null +++ b/public/locales/en/roadmap.json @@ -0,0 +1,44 @@ +{ + "modals": { + "roadmap": { + "title": "Roadmap" + } + }, + "title": "Roadmap", + "subtitle": "Next update", + "blurb": "I'm aiming for this update to release between late-January and early-February. I'm losing a week to top 2k in Guild Wars and after that I'm back at my full-time job, so progress will be a bit slower.", + "link": { + "intro": "You can see the full roadmap on Github below:", + "title": "granblue.team Roadmap" + }, + "roadmap": { + "item1": { + "title": "Remix teams", + "description": "See a team you want to riff off of? This update will let you remix other teams, which will add a copy to your account to make something new." + }, + "item2": { + "title": "Character mods", + "description": "This update will allow you to add rings, earrings, perpetuity rings and awakenings to your characters." + }, + "item3": { + "title": "Remove from grid", + "description": "This update will allow you to remove characters, summons, or weapons from your grid." + }, + "item4": { + "title": "Transcendence", + "description": "This update will allow you to set which transcendence stage characters or summons in your team are at." + }, + "item5": { + "title": "URL state for team tabs", + "description": "This update will allow you to append /characters, /weapons, /summons to link to individual tabs, and also /all to see everything at once." + }, + "item6": { + "title": "Add R characters", + "description": "I will spend several hours manually inputting R characters, just for you." + }, + "item7": { + "title": "Private and unlisted teams", + "description": "If you just want to save something for yourself, this update will let you change the visibility of teams so only you or people you share the link with can see them." + } + } +} diff --git a/public/locales/ja/roadmap.json b/public/locales/ja/roadmap.json new file mode 100644 index 00000000..d831c112 --- /dev/null +++ b/public/locales/ja/roadmap.json @@ -0,0 +1,44 @@ +{ + "modals": { + "roadmap": { + "title": "ロードマップ" + } + }, + "title": "ロードマップ", + "subtitle": "次回更新予定", + "blurb": "1月下旬〜2月上旬に更新する予定があります。火古戦場に2000位を狙っており、その後は仕事に戻るので開発はちょっとだけ遅くなります。", + "link": { + "intro": "全部のロードマップは以下のGithubリンクで:", + "title": "granblue.teamのロードマップ" + }, + "roadmap": { + "item1": { + "title": "編成をリミックス", + "description": "面白い編成を見出したら、リミックス機能で自分のアカウントにコピーし、アイテムを変えて新らたな編成を作れる" + }, + "item2": { + "title": "キャラクター変更", + "description": "指輪・御耳飾り・覚醒などキャラクターに付けるようになる" + }, + "item3": { + "title": "編成から外す", + "description": "キャラクター・武器・召喚石などを編成から外すようになる" + }, + "item4": { + "title": "限界超越", + "description": "編成にあるキャラクターや召喚石の限界超越のステージを記録するようになる" + }, + "item5": { + "title": "編成タブをURLで直接アクセス", + "description": "編成URLに/characters・/weapons・/summonsを追加したら、そのタブを直接にアクセスできるようになり、/allを追加したら全てのタブを一気に見えるようになる。" + }, + "item6": { + "title": "Rキャラ追加", + "description": "何時間もかかりますが追加します。" + }, + "item7": { + "title": "プライベートや未公開編成", + "description": "自分や友達だけのために編成を作成したいなら、プライベートまたは未公開設定でできる。" + } + } +} diff --git a/styles/themes.scss b/styles/themes.scss index 42befb43..b4024588 100644 --- a/styles/themes.scss +++ b/styles/themes.scss @@ -11,6 +11,8 @@ --full-auto-text: #{$text--full--auto--light}; + --separator-bg: #{$separator--bg--light}; + // Light - Menus --dialog-bg: #{$dialog--bg--light}; @@ -133,6 +135,8 @@ --full-auto-text: #{$text--full--auto--dark}; + --separator-bg: #{$separator--bg--dark}; + // Dark - Dialogs --dialog-bg: #{$dialog--bg--dark}; diff --git a/styles/variables.scss b/styles/variables.scss index 644fd05e..f785cf61 100644 --- a/styles/variables.scss +++ b/styles/variables.scss @@ -73,6 +73,7 @@ $orange-90: #ffebd9; // Colors -- Interface $blue: #275dc5; $red: #ff6161; +$yellow: #c89d39; $error: #d13a3a; // Colors -- Elements @@ -130,6 +131,9 @@ $page--hover--dark: $grey-30; $page--element--bg--light: $grey-70; $page--element--bg--dark: $grey-40; +$separator--bg--light: $grey-90; +$separator--bg--dark: $grey-15; + // Color Definitions: Dialog $dialog--bg--light: $grey-100; $dialog--bg--dark: $grey-25; @@ -250,7 +254,7 @@ $text--primary--color--light: $grey-40; $text--primary--color--dark: $grey-90; $text--secondary--color--light: $grey-60; -$text--secondary--color--dark: $grey-60; +$text--secondary--color--dark: $grey-70; $text--tertiary--color--light: $grey-50; $text--tertiary--color--dark: $grey-50; diff --git a/types/index.d.ts b/types/index.d.ts index 682437a1..b9bfc273 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -22,16 +22,18 @@ export type PaginationObject = { export type DetailsObject = { [key: string]: boolean | number | string | Raid | undefined - fullAuto: boolean - autoGuard: boolean - chargeAttack: boolean - clearTime: number + fullAuto?: boolean + autoGuard?: boolean + chargeAttack?: boolean + clearTime?: number buttonCount?: number turnCount?: number chainCount?: number name?: string description?: string raid?: Raid + job?: Job + extra?: boolean } export type ExtendedMastery = {