NEXT craftinamerica.org. Base setup for headless wordpress https://www.craftinamerica.org
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

navigation.vue 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. // Replace with calls to menu system
  2. <template lang="pug">
  3. nav.main.w-max
  4. .menu.f-col.t-up
  5. ul.f-row.w-max
  6. li.f-row.start
  7. router-link(to="/")
  8. img(aria-label="home button logo" src="../../star.svg")
  9. router-link(to="/")
  10. h1.t-serif craft in america
  11. //- hardcoded menu
  12. li.f-grow
  13. li.f-grow
  14. router-link(to="/episode") PBS Series
  15. ul.submenu
  16. li
  17. router-link(to="/episode") Episodes
  18. li
  19. router-link(to="/short") Shorts
  20. li
  21. router-link(to="/technique") Techniques
  22. li.f-grow
  23. router-link(to="/artist") Artists
  24. ul.submenu
  25. li
  26. router-link(to="/artist/sorted/by-alpha") A - Z
  27. li
  28. router-link(to="/artist/sorted/by-material") By Material
  29. li.f-grow
  30. router-link(to="/exhibition") Exhibitions
  31. ul.submenu
  32. li
  33. router-link(to="/exhibition/sorted/by-current-and-upcoming") Current/Upcoming
  34. li
  35. router-link(to="/exhibition/sorted/by-past") Past
  36. li.f-grow
  37. router-link(to="/page/center") Center
  38. ul.submenu
  39. li
  40. router-link(to="/page/center") Info
  41. li
  42. router-link(to="/event/sorted/by-current-and-upcoming") Events
  43. li
  44. router-link(to="/page/recorded-talks-and-interviews") Recorded Talks + Interviews
  45. li
  46. router-link(to="/page/library") Library
  47. li.f-grow
  48. router-link(to="/guide") Education
  49. ul.submenu
  50. li
  51. router-link(to="/guide") Education Guides
  52. li
  53. router-link(to="/page/video-resources-for-educators") Video Resources
  54. li
  55. router-link(to="/page/craft-in-schools") Craft in Schools
  56. li.f-grow
  57. router-link(to="/page/artists-resources") Resources
  58. ul.submenu
  59. li
  60. a(href="https://www.craftvideodictionary.org" target="_blank") Craft Video Dictionary Website
  61. li
  62. router-link(to="/publication") Publications
  63. li
  64. router-link(to="/object") Explore Craft Objects
  65. li
  66. router-link(to="/page/artists-resources") Opportunities
  67. li
  68. router-link(to="/artist/sorted/by-type") Organizations and Institutions
  69. li
  70. router-link(to="/page/craft-resources-map") Craft Resources Map
  71. li
  72. router-link(to="/page/community-craft-calendar") Community Craft Calendar
  73. li.f-grow
  74. router-link(to="/page/donate") Support
  75. ul.submenu
  76. li
  77. router-link(to="/page/donate") Donate
  78. li
  79. router-link(to="/page/shop") Shop
  80. li.f-grow
  81. router-link(to="/page/about") About
  82. ul.submenu
  83. li
  84. router-link(to="/page/about") Craft in America
  85. li
  86. router-link(to="/page/board") Board of Directors
  87. li
  88. router-link(to="/page/staff") Staff
  89. li
  90. router-link(to="/page/contact") Contact
  91. li.f-grow
  92. a(@click="toggleSearch") 🔍
  93. ul(v-if="isSearchOpen").search.w-max
  94. li.f-row.w-max
  95. input(v-model="searchTerms" @keyup.enter="sendSearch" tabindex="10")
  96. button.b-none.bg-none(@click="sendSearch" tabindex="11") 🔍 search
  97. .mobile-menu
  98. .f-row.start
  99. router-link(to="/")
  100. img(aria-label="home button logo" src="../../star.svg" )
  101. router-link(to="/")
  102. h1.t-serif.t-up craft in america
  103. label(for="toggle-mobile-menu" aria-label="Menu").drop-down &#9776;
  104. input(id="toggle-mobile-menu" type="checkbox").hide
  105. ul.drop-down.w-max.t-up
  106. li.f-col.center
  107. h5
  108. .search-item
  109. input(v-model="searchTerms" @keyup.enter="sendSearch" tabindex="10")
  110. button(@click="sendSearch" tabindex="11") &nbsp;🔍 search&nbsp;
  111. li(v-for="item in menuItems").f-row.center
  112. router-link(@click="uncheck" v-if="item == 'about' || item == 'donate' || item == 'center' || item == 'library'" :to="`/page/${item}`")
  113. h5 {{ item }}
  114. router-link(@click="uncheck" v-else= "" :to="`/${item}`")
  115. h5 {{ item }}
  116. </template>
  117. <script>
  118. import { computed, ref, nextTick } from '@vue/runtime-core'
  119. import { useRouter } from 'vue-router'
  120. import { postTypes, sortTypes } from '@/utils/helpers'
  121. export default {
  122. setup() {
  123. const router = useRouter()
  124. const searchTerms = ref('')
  125. const isSearchOpen = ref(false)
  126. const toggleSearch = () => {
  127. isSearchOpen.value = !isSearchOpen.value
  128. if(isSearchOpen.value) {
  129. nextTick(() => {
  130. const searchBox = document.querySelector('ul.search > li > input')
  131. searchBox.focus()
  132. })
  133. }
  134. }
  135. const sendSearch = () => {
  136. router.push({ path: '/search', query: { s: searchTerms.value } })
  137. searchTerms.value = ''
  138. toggleSearch()
  139. document.getElementById('toggle-mobile-menu').checked = false
  140. }
  141. /**
  142. * Navigation items
  143. * Auto-includes declared postTypes and extra items
  144. * TIP: Add things to the ignore array to remove from the nav
  145. */
  146. const menuItems = computed(() => {
  147. const extras = [
  148. 'center',
  149. 'library',
  150. 'blog',
  151. 'donate',
  152. 'about',
  153. ]
  154. const ignore = [
  155. 'page',
  156. 'post',
  157. 'sticky',
  158. ]
  159. const filtered = postTypes.filter(val => !ignore.includes(val))
  160. return [...filtered, ...extras]
  161. })
  162. const uncheck = () => {
  163. document.getElementById('toggle-mobile-menu').checked = false
  164. }
  165. return {
  166. sortTypes,
  167. menuItems,
  168. uncheck,
  169. searchTerms,
  170. sendSearch,
  171. toggleSearch,
  172. isSearchOpen
  173. }
  174. },
  175. }
  176. </script>
  177. <style lang="postcss">
  178. // prettier-ignore
  179. @import '../../sss/variables.sss'
  180. @import '../../sss/theme.sss'
  181. nav.main
  182. position: sticky
  183. top: 0
  184. background-color: $cia_grey
  185. word-wrap: break-word
  186. z-index: 10002
  187. .menu, .mobile-menu, .submenu
  188. a
  189. text-decoration: none
  190. color: $cia_black
  191. &:hover
  192. color: $cia_darker
  193. h1
  194. font-size: $ms-3
  195. font-weight: 400
  196. color: $cia_red
  197. text-decoration: none
  198. img
  199. width: $ms-3
  200. height: $ms-3
  201. padding: 0
  202. .menu > ul
  203. position: relative
  204. padding: 0 0 0 $ms-0
  205. &.search
  206. background-color: #fefefe
  207. box-shadow: 1px 1px 1px $lighter
  208. position: absolute
  209. top: 36px
  210. padding: 0
  211. input
  212. height: $ms-4
  213. vertical-align: middle
  214. width: 50%
  215. font-size: $ms-2
  216. .menu
  217. h1
  218. margin: $ms--7 0 0
  219. h5
  220. font-size: $ms--1
  221. font-weight: 400
  222. margin: 0
  223. img
  224. margin: 0 $ms--2 calc(-1 * $ms--6) 0
  225. > ul > li
  226. &:nth-child(1)
  227. a
  228. text-decoration: none
  229. &:nth-child(n+2)
  230. a > h5
  231. padding: $ms-1
  232. //- menu hover
  233. &:hover
  234. color: $cia_red1
  235. display: block
  236. cursor: pointer
  237. transition: $transition
  238. ul.submenu
  239. display: block
  240. ul.submenu
  241. display: none
  242. position: absolute
  243. /* background-image: linear-gradient(180deg, rgba(255,255,255, 0), $lighter, $lighter, $lighter, $lighter, $lighter, $lighter, $lighter, $lighter) */
  244. background-color: $lighter
  245. padding: 0.3em 0.3em 0.3em
  246. opacity: 0
  247. top: 24px
  248. //- submenu hover
  249. &:hover
  250. display: block
  251. opacity: 1
  252. transition: $transition
  253. > li
  254. line-height: 1.4
  255. /* width: max-content */
  256. /* background-color: $lighter */
  257. //- list hover
  258. /* &:hover
  259. display: block
  260. background-color: $lighter */
  261. .mobile-menu
  262. a
  263. /* cia logotype for smaller screens */
  264. img
  265. margin: $ms--7 $ms--6 0 $ms-0
  266. h1
  267. padding: $ms--4 0 0
  268. margin: 0 0 $ms--7 $ms--7
  269. /* hamburger menu drawer */
  270. label
  271. position: absolute
  272. right: 0
  273. top: 0
  274. padding: $ms--4 $ms--2
  275. font-size: $ms-2
  276. &:hover
  277. color: $cia_darker
  278. cursor: pointer
  279. /* make this menu style for $small min-width 480px screen */
  280. input, button
  281. height: $ms-6
  282. vertical-align: middle
  283. &.hide
  284. display: none
  285. cursor: pointer
  286. &:checked + ul
  287. display: block
  288. position: absolute
  289. width: 100%
  290. ul
  291. background-color: $cia_red
  292. display: none
  293. margin: 0.5px 0 0 0
  294. box-shadow: lightgrey $ms--7 $ms--7 $ms--7
  295. li
  296. /* color: $primary-light */
  297. &:hover
  298. /* color: $cia_red2 */
  299. background-color: $cia_red1
  300. transition: $transition
  301. h5
  302. /* font-size: $ms-0 */
  303. color: $cia_white
  304. padding: $ms--1
  305. /* padding: 0 */
  306. margin: 0
  307. @media (max-width: $large)
  308. .menu
  309. display: none
  310. @media (min-width: $large)
  311. .menu
  312. display: flex
  313. justify-content: center
  314. .mobile-menu
  315. display: none
  316. @media (min-width: $extra-large)
  317. .menu > ul
  318. max-width: $max-width
  319. </style>