so://phie

verbal

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

blob: 9ff3706b9909aff7b0b38978aa4fd9ee269a93d4 (4143 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

31 class="w-[54px] h-[54px] min-w-[54px] bg-zinc-900 rounded-lg overflow-hidden cursor-pointer"

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

33 >

34 <img

35 v-if="station.icon"

36 :alt="station.name"

37 :src="station.icon"

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

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

40 >

41 <v-icon

42 v-else

43 id="access-point"

44 size="32px"

45 class="text-gray-400"

46 ></v-icon>

47 </div>

48 <div class="flex flex-col flex-1 min-w-0 cursor-pointer">

49 <p

50 :title="station.name"

51 class="text-lg font-medium text-gray-100 pb-0 overflow-hidden text-ellipsis whitespace-nowrap"

52 >

53 {{station.name}}

54 </p>

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

56 <span

57 v-if="station.country"

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

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

60 >

61 <v-icon

62 id="world"

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

64 size="100%"

65 ></v-icon>

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

67 </span>

68 <span

69 v-if="station.votes"

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

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

72 >

73 <v-icon

74 id="thumb-up"

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

76 size="100%"

77 ></v-icon>

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

79 </span>

80 <span

81 v-if="station.click_trend"

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

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

84 >

85 <v-icon

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

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

88 ></v-icon>

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

90 </span>

91 </span>

92 </div>

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

94 <v-button

95 :icon="[ station.is_favorite ? 'bookmark-off' : 'bookmark' ]"

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

97 :active="station.is_favorite"

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

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

100 ></v-button>

101 </div>

102 </div>

103 `

104}