Skip to content

Commit

Permalink
Adding avatars & per sport league lists (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
sleeper-jasonl authored Dec 7, 2023
1 parent 902d72d commit 6883f27
Show file tree
Hide file tree
Showing 19 changed files with 209 additions and 135 deletions.
Empty file modified bin/build_mini.js
100644 → 100755
Empty file.
Empty file modified bin/preload_packages.js
100644 → 100755
Empty file.
23 changes: 23 additions & 0 deletions declarations/avatar/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from "react";
import { League, Player, User } from "@sleeperhq/mini-core/declarations/types/shared/graphql.d";
export interface AvatarProps {
user: User;
width?: number;
}
export declare const Avatar: React.MemoExoticComponent<(props: AvatarProps) => JSX.Element>;
export interface AvatarPlayerProps {
player: Player;
width?: number;
}
export declare const AvatarPlayer: React.MemoExoticComponent<(props: AvatarPlayerProps) => JSX.Element>;
export interface AvatarTeamProps {
team: string;
sport: string;
width?: number;
}
export declare const AvatarTeam: React.MemoExoticComponent<(props: AvatarTeamProps) => JSX.Element>;
export interface AvatarLeagueProps {
league: League;
width?: number;
}
export declare const AvatarLeague: React.MemoExoticComponent<(props: AvatarLeagueProps) => JSX.Element>;
5 changes: 2 additions & 3 deletions declarations/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './types';
export * from './sleeper_message';
declare const _default: any;
/// <reference types="react" />
declare const _default: (props: any) => JSX.Element;
export default _default;
2 changes: 1 addition & 1 deletion declarations/jersey/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ColorValue, ViewStyle } from 'react-native';
import SleeperJersey from 'components/ui/jersey';
import SleeperJersey from '@sleeperhq/mini-core/declarations/types/components/jersey.d';
export interface JerseyProps {
style: ViewStyle;
sport: 'nfl' | 'nba' | 'cbb' | 'cfb' | 'mlb';
Expand Down
2 changes: 1 addition & 1 deletion declarations/navigation/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { LeagueId, PlayerId, RosterId, SportType, TransactionId } from '..';
import type { LeagueId, PlayerId, RosterId, SportType, TransactionId } from '@sleeperhq/mini-core/declarations/types';
export type NavigationParams = {
LeaguesIndexScreen: undefined;
LeaguesDetailScreen: LeaguesDetailScreenParams;
Expand Down
2 changes: 1 addition & 1 deletion declarations/sleeper_actions.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NavigationParams, NavigationScreen, ToastConfig, Notification } from './types';
import { NavigationParams, NavigationScreen, ToastConfig, Notification } from '@sleeperhq/mini-core/declarations/types';
export type SleeperActions = {
navigate?: <T extends NavigationScreen>(screen: T, params?: NavigationParams[T]) => void;
requestLocation?: () => void;
Expand Down
6 changes: 4 additions & 2 deletions declarations/sleeper_context.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { User, League, LeaguesMap, RostersInLeagueMap, UserMap, MatchupsInLeagueMap, UsersInLeagueMap, PlayoffsInLeagueMap, TransactionsInLeagueMap, TransactionsMap, SportInfoMap, DraftsInLeagueMap, DraftPickTradesInLeagueMap, DraftPicksInDraftMap, PlayersInSportMap, Topic, Location } from './types';
import type { SleeperActions } from './sleeper_actions';
import { User, League, LeaguesMap, RostersInLeagueMap, UserMap, MatchupsInLeagueMap, UsersInLeagueMap, PlayoffsInLeagueMap, TransactionsInLeagueMap, TransactionsMap, SportInfoMap, DraftsInLeagueMap, DraftPickTradesInLeagueMap, DraftPicksInDraftMap, PlayersInSportMap, Topic, Location, SportType } from '@sleeperhq/mini-core/declarations/types';
import type { SleeperActions } from '@sleeperhq/mini-core/declarations/sleeper_actions';
declare class SleeperContext {
static apiLevel: string;
user: User;
league: League;
leaguesMap: LeaguesMap;
leaguesMapBySport: Record<SportType, LeaguesMap>;
userLeagueList: string[];
userLeagueListBySport: Record<SportType, string[]>;
rostersInLeagueMap: RostersInLeagueMap;
userMap: UserMap;
matchupsInLeagueMap: MatchupsInLeagueMap;
Expand Down
3 changes: 2 additions & 1 deletion declarations/sleeper_message.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Entitlement, HeaderOptions } from './types';
import type { Entitlement, HeaderOptions, Metadata } from '@sleeperhq/mini-core/declarations/types';
type SocketMessage = {
_ip?: string;
_name?: string;
Expand All @@ -7,5 +7,6 @@ type SocketMessage = {
_description?: string;
_entitlements?: Entitlement[];
_headerOptions?: HeaderOptions;
_metadata?: Metadata;
};
export default SocketMessage;
4 changes: 2 additions & 2 deletions declarations/switch/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { AppIconSwitch } from '../types/components/ui_2/app_icon_switch';
export type { SwitchOption, Props as SwitchProps } from '../types/components/ui_2/app_icon_switch';
import { AppIconSwitch } from '@sleeperhq/mini-core/declarations/types/components/app_icon_switch.d';
export type { SwitchOption, Props as SwitchProps } from '@sleeperhq/mini-core/declarations/types/components/app_icon_switch.d';
export default AppIconSwitch;
24 changes: 24 additions & 0 deletions declarations/types/components/app_icon_switch.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import { StyleProp, ViewStyle } from 'react-native';
export type SwitchOption = {
colorToggleActive: string;
colorIconActive: string;
colorIconInactive?: string;
iconStyle?: any;
icon: any;
iconInactive?: any;
text?: string;
hideIconInactive?: boolean;
};
export type Props = {
options: [SwitchOption, SwitchOption];
value?: number;
onChange?: (value: number) => void;
height?: number;
width?: number;
containerStyle?: StyleProp<ViewStyle>;
toggleStyle?: StyleProp<ViewStyle>;
aspectRatio?: number;
confirmationFunction?: (nextSelection: 'on' | 'off', continueAction: () => void) => void;
};
export declare const AppIconSwitch: React.MemoExoticComponent<({ height, options, value, width, onChange, containerStyle, toggleStyle, aspectRatio, confirmationFunction }: Props) => JSX.Element>;
3 changes: 3 additions & 0 deletions declarations/types/components/jersey.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default Jersey;
declare const Jersey: React.NamedExoticComponent<object>;
import React from 'react';
18 changes: 0 additions & 18 deletions declarations/types/components/ui_2/app_icon_switch.d.ts

This file was deleted.

83 changes: 9 additions & 74 deletions declarations/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,83 +1,17 @@
import { League, Roster, User, MatchupLeg, LeagueTransaction, Draft, DraftPick, RosterDraftPick, Player, Topic } from './shared/graphql.d';
import type { ToastConfig as ToastConfigOriginal } from './utils/toast_helper';
export * from './shared/graphql.d';
export * from '../navigation/index.d';
export type LeagueId = string;
export type RosterId = string;
export type UserId = string;
export type MatchupWeek = number;
export type MatchId = string;
export type TransactionId = string;
export type SportType = string;
export type DraftId = string;
export type PlayerId = string;
export type TopicId = 'podcasts' | 'videos';
export type { Topic };
export type BracketFrom = {
w?: RosterId;
l?: RosterId;
};
export type Bracket = {
round: number;
matchId: MatchId;
t1: RosterId;
t2: RosterId;
w: RosterId;
l: RosterId;
t1_from: BracketFrom;
t2_from: BracketFrom;
};
export type BracketSet = {
bracket: Bracket[];
loserBracket: Bracket[];
};
export type SportInfo = {
season_type: string;
season: string;
week?: number;
display_week?: number;
leg?: number;
league_season?: string;
league_create_season?: string;
previous_season?: string;
season_start_date?: string;
season_end_date?: string;
};
export type LeaguesMap = Record<LeagueId, League>;
export type RostersMap = Record<RosterId, Roster>;
export type RostersInLeagueMap = Record<LeagueId, RostersMap>;
export type UserMap = Record<UserId, User>;
export type MathchupWeekMap = Record<MatchupWeek, MatchupLeg>;
export type MatchupsInLeagueMap = Record<LeagueId, MathchupWeekMap>;
export type UsersInLeagueMap = Record<LeagueId, UserMap>;
export type PlayoffsInLeagueMap = Record<LeagueId, BracketSet>;
export type TransactionsInLeagueMap = Record<LeagueId, TransactionId[]>;
export type TransactionsMap = Record<TransactionId, LeagueTransaction>;
export type SportInfoMap = Record<SportType, SportInfo>;
export type DraftsInLeagueMap = Record<LeagueId, Draft[]>;
export type DraftPickTradesInLeagueMap = Record<LeagueId, RosterDraftPick[]>;
export type DraftPicksInDraftMap = Record<DraftId, DraftPick[]>;
export type PlayersMap = Record<PlayerId, Player>;
export type PlayersInSportMap = Record<SportType, PlayersMap>;
import type { ToastConfig as ToastConfigOriginal } from '@sleeperhq/mini-core/declarations/types/utils/toast_helper.d';
import { SportType } from '@sleeperhq/mini-core/declarations/types/minis/index.d';
export * from '@sleeperhq/mini-core/declarations/navigation/index.d';
export * from '@sleeperhq/mini-core/declarations/types/shared/graphql.d';
export * from '@sleeperhq/mini-core/declarations/types/minis/index.d';
export type Entitlement = 'user:email' | 'user:phone' | 'wallet:date_of_birth' | 'wallet:first_name' | 'wallet:last_name' | 'wallet:country_code' | 'wallet:city' | 'location:longitude' | 'location:latitude' | 'location:state' | 'location:country' | 'location:postalCode' | 'action:push_notification';
export type Entitlements = Partial<Record<Entitlement, any>>;
export declare const EntitlementDisplayText: Record<Entitlement, string>;
export type Notification = {
title?: string | undefined;
body?: string | undefined;
timestamp?: number;
};
export declare const EventHandlerResult: {
readonly CONSUMED: "CONSUMED";
readonly PROPAGATE: "PROPAGATE";
};
export type EventHandlerResultType = typeof EventHandlerResult[keyof typeof EventHandlerResult];
export type Events = {
onBackButtonPressed?: () => EventHandlerResultType;
};
export type HeaderOptions = {
useLeagueSelector?: boolean;
};
export type Metadata = {
sports?: SportType[];
};
export type Mini = {
name: string;
description: string;
Expand All @@ -86,6 +20,7 @@ export type Mini = {
email?: string;
entitlements?: Entitlement[];
headerOptions?: HeaderOptions;
metadata?: Metadata;
};
export type Location = {
state: string;
Expand Down
71 changes: 71 additions & 0 deletions declarations/types/minis/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import type { League, Roster, User, MatchupLeg, LeagueTransaction, Draft, DraftPick, RosterDraftPick, Player, Topic } from '@sleeperhq/mini-core/declarations/types/shared/graphql.d';
export type LeagueId = string;
export type RosterId = string;
export type UserId = string;
export type MatchupWeek = number;
export type MatchId = string;
export type TransactionId = string;
export type SportType = string;
export type DraftId = string;
export type PlayerId = string;
export type TopicId = 'podcasts' | 'videos';
export type { Topic };
export type BracketFrom = {
w?: RosterId;
l?: RosterId;
};
export type Bracket = {
round: number;
matchId: MatchId;
t1: RosterId;
t2: RosterId;
w: RosterId;
l: RosterId;
t1_from: BracketFrom;
t2_from: BracketFrom;
};
export type BracketSet = {
bracket: Bracket[];
loserBracket: Bracket[];
};
export type SportInfo = {
season_type: string;
season: string;
week?: number;
display_week?: number;
leg?: number;
league_season?: string;
league_create_season?: string;
previous_season?: string;
season_start_date?: string;
season_end_date?: string;
};
export type LeaguesMap = Record<LeagueId, League>;
export type RostersMap = Record<RosterId, Roster>;
export type RostersInLeagueMap = Record<LeagueId, RostersMap>;
export type UserMap = Record<UserId, User>;
export type MathchupWeekMap = Record<MatchupWeek, MatchupLeg>;
export type MatchupsInLeagueMap = Record<LeagueId, MathchupWeekMap>;
export type UsersInLeagueMap = Record<LeagueId, UserMap>;
export type PlayoffsInLeagueMap = Record<LeagueId, BracketSet>;
export type TransactionsInLeagueMap = Record<LeagueId, TransactionId[]>;
export type TransactionsMap = Record<TransactionId, LeagueTransaction>;
export type SportInfoMap = Record<SportType, SportInfo>;
export type DraftsInLeagueMap = Record<LeagueId, Draft[]>;
export type DraftPickTradesInLeagueMap = Record<LeagueId, RosterDraftPick[]>;
export type DraftPicksInDraftMap = Record<DraftId, DraftPick[]>;
export type PlayersMap = Record<PlayerId, Player>;
export type PlayersInSportMap = Record<SportType, PlayersMap>;
export type Notification = {
title?: string | undefined;
body?: string | undefined;
timestamp?: number;
};
export declare const EventHandlerResult: {
readonly CONSUMED: "CONSUMED";
readonly PROPAGATE: "PROPAGATE";
};
export type EventHandlerResultType = typeof EventHandlerResult[keyof typeof EventHandlerResult];
export type Events = {
onBackButtonPressed?: () => EventHandlerResultType;
};
57 changes: 29 additions & 28 deletions declarations/types/shared/graphql.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,35 @@ export type RosterDraftPick = {
round?: Maybe<Scalars['Int']>;
season?: Maybe<Scalars['String']>;
};
export type Topic = {
__typename?: 'Topic';
attachment?: Maybe<Scalars['Json']>;
author_avatar?: Maybe<Scalars['String']>;
author_display_name?: Maybe<Scalars['String']>;
author_id?: Maybe<Scalars['Snowflake']>;
author_is_bot?: Maybe<Scalars['Boolean']>;
channel_id?: Maybe<Scalars['Snowflake']>;
channel_tags?: Maybe<Scalars['Set']>;
client_id?: Maybe<Scalars['String']>;
created?: Maybe<Scalars['Int']>;
hidden?: Maybe<Scalars['Boolean']>;
last_message_id?: Maybe<Scalars['Snowflake']>;
last_pinned_message_id?: Maybe<Scalars['Snowflake']>;
last_read_id?: Maybe<Scalars['Snowflake']>;
num_messages?: Maybe<Scalars['Int']>;
num_viewers?: Maybe<Scalars['Int']>;
pinned?: Maybe<Scalars['Boolean']>;
player_tags?: Maybe<Scalars['Set']>;
pushed_by?: Maybe<Scalars['Json']>;
score?: Maybe<Scalars['Int']>;
shadowed?: Maybe<Scalars['Boolean']>;
shard_max?: Maybe<Scalars['Int']>;
shard_min?: Maybe<Scalars['Int']>;
title?: Maybe<Scalars['String']>;
title_map?: Maybe<Scalars['Json']>;
topic_id?: Maybe<Scalars['Snowflake']>;
upvotes?: Maybe<Scalars['Int']>;
};
export type User = {
__typename?: 'User';
async_bundles?: Maybe<Scalars['List']>;
Expand All @@ -227,31 +256,3 @@ export type User = {
username?: Maybe<Scalars['String']>;
verification?: Maybe<Scalars['String']>;
};
export type Topic = {
__typename?: 'Topic';
attachment?: Maybe<Scalars['Json']>;
author_avatar?: Maybe<Scalars['String']>;
author_display_name?: Maybe<Scalars['String']>;
author_id?: Maybe<Scalars['Snowflake']>;
author_is_bot?: Maybe<Scalars['Boolean']>;
channel_id?: Maybe<Scalars['Snowflake']>;
channel_tags?: Maybe<Scalars['Set']>;
client_id?: Maybe<Scalars['String']>;
created?: Maybe<Scalars['Int']>;
hidden?: Maybe<Scalars['Boolean']>;
last_message_id?: Maybe<Scalars['Snowflake']>;
last_pinned_message_id?: Maybe<Scalars['Snowflake']>;
last_read_id?: Maybe<Scalars['Snowflake']>;
num_messages?: Maybe<Scalars['Int']>;
num_viewers?: Maybe<Scalars['Int']>;
pinned?: Maybe<Scalars['Boolean']>;
player_tags?: Maybe<Scalars['Set']>;
pushed_by?: Maybe<Scalars['Json']>;
score?: Maybe<Scalars['Int']>;
shard_max?: Maybe<Scalars['Int']>;
shard_min?: Maybe<Scalars['Int']>;
title?: Maybe<Scalars['String']>;
title_map?: Maybe<Scalars['Json']>;
topic_id?: Maybe<Scalars['Snowflake']>;
upvotes?: Maybe<Scalars['Int']>;
};
2 changes: 1 addition & 1 deletion declarations/types/utils/toast_helper.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TextStyle, ViewStyle } from 'react-native';
export type ToastConfig = {
text: string;
icon?: string;
icon?: 'success' | 'error' | 'trade' | 'voice';
time?: number;
style?: ViewStyle;
slideTop?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sleeperhq/mini-core",
"version": "1.6.2",
"version": "1.7.3",
"description": "Core library frameworks for developing Sleeper Mini Apps.",
"main": "index.ts",
"types": "index.d.ts",
Expand Down Expand Up @@ -66,7 +66,7 @@
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"babel-jest": "^26.6.3",
"eslint": "7.14.0",
"eslint": "8.38.0",
"jest": "^26.6.3",
"lodash": "4.17.21",
"metro-react-native-babel-preset": "^0.66.2",
Expand Down
Loading

0 comments on commit 6883f27

Please sign in to comment.