so://phie

verbal

A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal

blob: d84eeeb4f9cd0fbacc9b5e37eee2eac7ae6baa56 (4186 bytes)[doc][blame][raw]

1import {state} from '../main.js';

2import {$lang, http} from '../utils.js';

3import VButton from '../element/button.js';

4import VIcon from '../element/icon.js';

5

6export default {

7 props: ['station'],

8 components: {

9 VButton,

10 VIcon

11 },

12 methods: {

13 $lang,

14 async setLike(is_favorite) {

15 try {

16 await http`${is_favorite ? 'post' : 'delete'}::/api/favorite`(this.station.id);

17 this.station.is_favorite = is_favorite;

18 state.app.$refs.favorites.doFetch();

19 }

20 catch(error) {

21 console.log(error);

22 }

23 },

24 setStation(station) {

25 state.station = station;

26 }

27 },

28 template: `

29 <div class="w-full gap-4 group flex items-center">

30 <div class="w-[54px] h-[54px] min-w-[54px] bg-zinc-900 rounded-lg overflow-hidden">

31 <img

32 v-if="station.icon"

33 :alt="station.name"

34 :src="station.icon"

35 @error="() => station.icon = null"

36 class="w-full h-full object-contain"

37 >

38 <v-icon

39 v-else

40 id="access-point"

41 size="32px"

42 class="text-gray-400"

43 ></v-icon>

44 </div>

45 <div class="flex flex-col flex-1 min-w-0">

46 <p :title="station.name" class="text-lg font-medium text-gray-100 pb-0 overflow-hidden text-ellipsis whitespace-nowrap">{{station.name}}</p>

47 <span class="text-md text-gray-400 overflow-hidden flex gap-2 sm:gap-3">

48 <span

49 v-if="station.country"

50 class="text-gray-400 inline-flex items-center gap-[5px]"

51 :title="$lang('global.country')"

52 >

53 <v-icon

54 id="world"

55 class="w-[18px] h-[18px] !min-w-[18px] inline-flex text-gray-400"

56 size="100%"

57 ></v-icon>

58 <p>{{station.country}}</p>

59 </span>

60 <span

61 v-if="station.votes"

62 class="text-gray-400 inline-flex items-center gap-[5px]"

63 :title="$lang('global.votes')"

64 >

65 <v-icon

66 id="thumb-up"

67 class="w-[18px] h-[18px] !min-w-[18px] inline-flex text-gray-400"

68 size="100%"

69 ></v-icon>

70 <p>{{station.votes}}</p>

71 </span>

72 <span

73 v-if="station.click_trend"

74 class="text-gray-400 hidden sm:inline-flex items-center gap-[5px]"

75 :title="$lang('global.trend')"

76 >

77 <v-icon

78 :id="[ station.click_trend >= 0 ? 'arrow-up-right' : 'arrow-down-right' ]"

79 class="w-[18px] h-[18px] !min-w-[18px] inline-flex text-gray-400"

80 ></v-icon>

81 <p>{{Math.abs(station.click_trend) ?? 'None'}}</p>

82 </span>

83 </span>

84 </div>

85 <div class="inline-flex gap-3 sm:gap-4">

86 <v-button

87 :icon="[ station.is_favorite ? 'heart-off' : 'heart' ]"

88 :title="[ $lang(station.is_favorite ? 'global.unlike' : 'global.like') ]"

89 :active="station.is_favorite"

90 @click="() => setLike(!station.is_favorite)"

91 class="bg-zinc-900 hover:bg-white"

92 ></v-button>

93 <v-button

94 icon="player-play"

95 class="bg-zinc-900 hover:bg-white"

96 :title="$lang('global.play')"

97 @click="() => setStation(station)"

98 ></v-button>

99 </div>

100 </div>

101 `

102}