paginar 0.2.7 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/style.css CHANGED
@@ -608,10 +608,6 @@ video {
608
608
  right: -0.5rem;
609
609
  }
610
610
 
611
- .-left-2 {
612
- left: -0.5rem;
613
- }
614
-
615
611
  .z-20 {
616
612
  z-index: 20;
617
613
  }
@@ -767,6 +763,10 @@ video {
767
763
  cursor: pointer;
768
764
  }
769
765
 
766
+ .cursor-default {
767
+ cursor: default;
768
+ }
769
+
770
770
  .grid-cols-3 {
771
771
  grid-template-columns: repeat(3, minmax(0, 1fr));
772
772
  }
@@ -913,6 +913,11 @@ video {
913
913
  text-align: center;
914
914
  }
915
915
 
916
+ .text-sm {
917
+ font-size: 0.875rem;
918
+ line-height: 1.25rem;
919
+ }
920
+
916
921
  .text-xs {
917
922
  font-size: 0.75rem;
918
923
  line-height: 1rem;
@@ -967,14 +972,14 @@ video {
967
972
  opacity: 0;
968
973
  }
969
974
 
970
- .opacity-75 {
971
- opacity: 0.75;
972
- }
973
-
974
975
  .opacity-30 {
975
976
  opacity: 0.3;
976
977
  }
977
978
 
979
+ .opacity-75 {
980
+ opacity: 0.75;
981
+ }
982
+
978
983
  .shadow-2xl {
979
984
  --tw-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
980
985
  --tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);
@@ -1068,10 +1073,6 @@ video {
1068
1073
  right: 4rem;
1069
1074
  }
1070
1075
 
1071
- .md\:left-16 {
1072
- left: 4rem;
1073
- }
1074
-
1075
1076
  .md\:flex {
1076
1077
  display: flex;
1077
1078
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "description": "A flipping page web component for reading long texts on the brower",
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",
7
- "version": "0.2.7",
7
+ "version": "0.3.0",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/educkf/paginar.git"
package/src/App.ce.vue CHANGED
@@ -30,8 +30,8 @@ const props = defineProps({
30
30
  cssString: String
31
31
  })
32
32
 
33
- const { initSettings, baseFont, textFont, fontSize, columns, setColumns, mode } = useReaderSettings
34
- const { currentPage, totalPages, init } = usePagination
33
+ const { baseFont, bookTitle, chapterTitle, textFont, fontSize, columns, setColumns, mode } = useReaderSettings
34
+ const { currentPage, totalPages } = usePagination
35
35
  const { content, listenToClicks } = useTextContent
36
36
  const { width, height } = useWindowSize()
37
37
 
@@ -40,31 +40,23 @@ const contentArea = ref(null)
40
40
  const rootComponent = ref(null)
41
41
 
42
42
  onMounted(async () => {
43
- init(readerComponent, contentArea)
44
- initSettings(props.readerSettings)
43
+ usePagination.init(readerComponent, contentArea)
44
+ useReaderSettings.initSettings(props.readerSettings)
45
+ useStyles.initStyles(props, rootComponent)
45
46
 
46
47
  if (['string', 'boolean'].includes(typeof props.readerBlocked)) {
47
48
  useReaderSettings.setBlocked(props.readerBlocked)
48
49
  }
49
50
 
50
- if (props.cssFile) {
51
- useStyles.stylesheetLoader(props.cssFile, rootComponent)
52
- }
53
-
54
- if (props.cssString) {
55
- useStyles.applyStylesheet(props.cssString, rootComponent)
56
- }
57
51
  })
58
52
 
59
53
  watch(
60
54
  props,
61
55
  () => {
62
- console.log(props)
63
56
  if (props.hasOwnProperty('readerBlocked')) {
64
57
  const readerBlocked = typeof props.readerBlocked === 'boolean'
65
58
  ? props.readerBlocked
66
59
  : props.readerBlocked === 'true'
67
- console.log(readerBlocked)
68
60
  useReaderSettings.setBlocked(readerBlocked)
69
61
  }
70
62
  }
@@ -103,8 +95,11 @@ watchDebounced(content,
103
95
  <HeaderSlot>
104
96
  <template #header>
105
97
  <slot name="header">
98
+ <p class="text-white text-center text-sm">
99
+ {{ props.bookTitle || bookTitle }}
100
+ </p>
106
101
  <p class="text-white text-center text-xs">
107
- {{ props.bookTitle }}
102
+ {{ props.chapterTitle || chapterTitle }}
108
103
  </p>
109
104
  </slot>
110
105
  </template>
@@ -4,7 +4,7 @@ import OptionsButton from './OptionsButton/OptionsButton.vue';
4
4
  </script>
5
5
 
6
6
  <template>
7
- <div class="bg-primary flex justify-between items-center p-4">
7
+ <header id="component-header" class="bg-primary flex justify-between items-center p-4">
8
8
  <summary-button>
9
9
  <template #summaryTop>
10
10
  <slot name="summaryTop" />
@@ -14,7 +14,7 @@ import OptionsButton from './OptionsButton/OptionsButton.vue';
14
14
  </template>
15
15
  </summary-button>
16
16
 
17
- <div>
17
+ <div id="header-titles">
18
18
  <slot name="header" />
19
19
  </div>
20
20
 
@@ -26,5 +26,5 @@ import OptionsButton from './OptionsButton/OptionsButton.vue';
26
26
  <slot name="optionsBottom" />
27
27
  </template>
28
28
  </options-button>
29
- </div>
29
+ </header>
30
30
  </template>
@@ -26,11 +26,11 @@ const { toggle: toggleFullScreen } = useFullscreen()
26
26
  </script>
27
27
 
28
28
  <template>
29
- <div ref="button" class="relative">
29
+ <div id="options-menu" ref="button" class="relative">
30
30
  <div class="flex">
31
31
  <button @click.prevent="toggleSummary()"
32
32
  class="border p-3 shadow flex items-center border-white text-white"
33
- id="summary-menu" aria-haspopup="true" :aria-expanded="show"
33
+ id="options-button" aria-haspopup="true" :aria-expanded="show"
34
34
  >
35
35
  <span class="block mr-3">
36
36
  Opções
@@ -8,7 +8,7 @@ const { mode, setMode } = useReaderSettings
8
8
  </script>
9
9
 
10
10
  <template>
11
- <button @click.prevent="setMode('light')"
11
+ <button id="lightmode-button" @click.prevent="setMode('light')"
12
12
  title="Leitura diurna"
13
13
  class="font-light text-base border w-full h-10 flex justify-center items-center"
14
14
  :class="{
@@ -17,7 +17,7 @@ const { mode, setMode } = useReaderSettings
17
17
  <IconSun class="w-5 h-5" />
18
18
  </button>
19
19
 
20
- <button @click.prevent="setMode('dark')"
20
+ <button id="darkmode-button" @click.prevent="setMode('dark')"
21
21
  title="Leitura noturna"
22
22
  class="font-light text-base border w-full h-10 flex justify-center items-center"
23
23
  :class="{
@@ -17,8 +17,9 @@ const isSafari = computed(() => {
17
17
  </script>
18
18
 
19
19
  <template>
20
- <div class="w-full hidden md:grid grid-cols-3 gap-2 mt-3">
20
+ <div id="columns-menu" class="w-full hidden md:grid grid-cols-3 gap-2 mt-3">
21
21
  <button
22
+ id="single-column-button"
22
23
  class="col-span-1 text-primary text-center cursor-pointer py-3 rounded-sm border"
23
24
  :class="{
24
25
  'border-gray-300': columns !== 'single',
@@ -33,6 +34,7 @@ const isSafari = computed(() => {
33
34
  </button>
34
35
 
35
36
  <button
37
+ id="double-column-button"
36
38
  class="col-span-2 text-primary text-center cursor-pointer py-3 rounded-sm border"
37
39
  :class="{
38
40
  'border-gray-300': columns !== 'double',
@@ -23,17 +23,21 @@ import useFootnotes from '../../../composables/useFootnotes'
23
23
 
24
24
  <slot name="optionsTop" />
25
25
 
26
- <button @click.prevent="useFootnotes.setShowFootnotes(true)"
27
- class="w-full flex justify-center items-center py-3 lowercase"
28
- >
29
- <IconFootnote class="w-6 h-6" />
30
- <span class="ml-4">Notas de rodapé</span>
31
- </button>
32
-
33
- <div class="w-full border-b border-areia my-3"></div>
26
+ <div id="footnotes-button">
27
+ <button @click.prevent="useFootnotes.setShowFootnotes(true)"
28
+ class="w-full flex justify-center items-center py-3 lowercase"
29
+ >
30
+ <IconFootnote class="w-6 h-6" />
31
+ <span class="ml-4">Notas de rodapé</span>
32
+ </button>
33
+
34
+ <div class="w-full border-b border-areia my-3"></div>
35
+ </div>
34
36
 
35
37
 
36
- <div class="w-full flex justify-center items-center py-3 lowercase">
38
+ <div class="w-full flex justify-center items-center py-3 lowercase"
39
+ id="visualize-title"
40
+ >
37
41
  <IconEye class="w-6 h-6" />
38
42
  <span class="ml-4">Visualização</span>
39
43
  </div>
@@ -5,7 +5,7 @@ const { textFont, fontsOptions, setTextFont } = useReaderSettings
5
5
  </script>
6
6
 
7
7
  <template>
8
- <div class="w-full grid grid-cols-4 gap-2 my-3">
8
+ <div id="font-family-menu" class="w-full grid grid-cols-4 gap-2 my-3">
9
9
  <button v-for="font in fontsOptions" :key="font.name" @click.prevent="setTextFont(font.name)"
10
10
  class="font-light text-lg text-primary tracking-wide border border-urucum w-full h-10 flex justify-center items-center"
11
11
  :class="{
@@ -5,12 +5,12 @@ const { fontSize, setFontSize } = useReaderSettings
5
5
  </script>
6
6
 
7
7
  <template>
8
- <button @click.prevent="setFontSize(fontSize + 1)"
8
+ <button id="fontsize-add-button" @click.prevent="setFontSize(fontSize + 1)"
9
9
  class="font-light text-base border border-urucum w-full h-10 flex justify-center items-center">
10
10
  + A
11
11
  </button>
12
12
 
13
- <button @click.prevent="setFontSize(fontSize - 1)"
13
+ <button id="fontsize-subtr-button" @click.prevent="setFontSize(fontSize - 1)"
14
14
  class="font-light text-base border border-urucum w-full h-10 flex justify-center items-center">
15
15
  - A
16
16
  </button>
@@ -12,6 +12,8 @@ import SummaryDropdown from './SummaryDropdown.vue'
12
12
  const show = ref(false)
13
13
  const button = ref(null)
14
14
 
15
+ const { homeUrl } = useReaderSettings
16
+
15
17
  const toggleSummary = () => show.value = !show.value
16
18
  const hide = () => {
17
19
  if (!useReaderSettings.blocked.value) {
@@ -24,42 +26,45 @@ onKeyStroke('Escape', () => hide())
24
26
  </script>
25
27
 
26
28
  <template>
27
- <div ref="button" class="relative">
29
+ <div id="summary-menu" ref="button" class="relative">
28
30
  <div class="flex">
29
- <a href="/" title="Homepage"
31
+ <a v-if="homeUrl"
32
+ :href="homeUrl" title="Homepage" id="home-button"
30
33
  class="hidden md:flex items-center border p-3 shadow mr-3
31
34
  border-white text-white"
32
35
  >
33
36
  <IconHome class="w-6 h-6"/>
34
37
  </a>
35
38
 
36
- <button
37
- @click.prevent="toggleSummary()"
38
- class="border p-3 shadow flex items-center border-white text-white"
39
- id="summary-menu" aria-haspopup="true" :aria-expanded="show"
40
- >
41
- <IconSummary v-if="!show" />
42
- <IconClose v-else class="w-6 h-6" />
39
+ <div class="position-relative">
40
+ <button
41
+ @click.prevent="toggleSummary()"
42
+ class="border p-3 shadow flex items-center border-white text-white"
43
+ id="summary-button" aria-haspopup="true" :aria-expanded="show"
44
+ >
45
+ <IconSummary v-if="!show" />
46
+ <IconClose v-else class="w-6 h-6" />
43
47
 
44
- <span class="block ml-3">
45
- Sumário
46
- </span>
47
- </button>
48
- </div>
48
+ <span class="block ml-3">
49
+ Sumário
50
+ </span>
51
+ </button>
49
52
 
50
- <transition enter-active-class="transition ease-out duration-100 transform" enter-class="opacity-0 scale-95"
51
- enter-to-class="opacity-100 scale-100" leave-active-class="transition ease-in duration-75 transform"
52
- leave-class="opacity-100 scale-100" leave-to-class="opacity-0 scale-95"
53
- >
54
- <SummaryDropdown v-if="show">
55
- <template #summaryTop>
56
- <slot name="summaryTop"/>
57
- </template>
53
+ <transition enter-active-class="transition ease-out duration-100 transform" enter-class="opacity-0 scale-95"
54
+ enter-to-class="opacity-100 scale-100" leave-active-class="transition ease-in duration-75 transform"
55
+ leave-class="opacity-100 scale-100" leave-to-class="opacity-0 scale-95"
56
+ >
57
+ <SummaryDropdown v-if="show">
58
+ <template #summaryTop>
59
+ <slot name="summaryTop"/>
60
+ </template>
58
61
 
59
- <template #summaryBottom>
60
- <slot name="summaryBottom"/>
61
- </template>
62
- </SummaryDropdown>
63
- </transition>
62
+ <template #summaryBottom>
63
+ <slot name="summaryBottom"/>
64
+ </template>
65
+ </SummaryDropdown>
66
+ </transition>
67
+ </div>
68
+ </div>
64
69
  </div>
65
70
  </template>
@@ -12,7 +12,7 @@ async function getChapter(item) {
12
12
 
13
13
  <template>
14
14
  <div class="absolute top-14 py-4 px-3 shadow-lg w-60 md:w-104
15
- text-areia -left-2 md:left-16 z-10 bg-white" :role="Sumário" aria-orientation="vertical"
15
+ text-areia z-10 bg-white" :role="Sumário" aria-orientation="vertical"
16
16
  aria-labelledby="summary-menu">
17
17
  <nav>
18
18
  <slot name="summaryTop" />
@@ -13,7 +13,11 @@ const state = reactive({
13
13
  fontSize: 16,
14
14
  columns: 'double',
15
15
  mode: 'light',
16
- blocked: false
16
+ blocked: false,
17
+
18
+ bookTitle: null,
19
+ chapterTitle: null,
20
+ homeUrl: null,
17
21
  })
18
22
 
19
23
  const baseFont = computed(() => state.baseFont)
@@ -24,6 +28,10 @@ const columns = computed(() => state.columns)
24
28
  const mode = computed(() => state.mode)
25
29
  const blocked = computed(() => state.blocked)
26
30
 
31
+ const bookTitle = computed(() => state.bookTitle)
32
+ const chapterTitle = computed(() => state.chapterTitle)
33
+ const homeUrl = computed(() => state.homeUrl)
34
+
27
35
  watch(
28
36
  [baseFont, textFont, fontSize, columns, mode],
29
37
  () => saveSettings()
@@ -62,6 +70,15 @@ async function initSettings(settingsString) {
62
70
  state.textFont = defaultTextFont.name
63
71
  }
64
72
 
73
+ if (settings?.bookTitle)
74
+ state.bookTitle = settings.bookTitle
75
+
76
+ if (settings?.chapterTitle)
77
+ state.chapterTitle = settings.chapterTitle
78
+
79
+ if (settings?.homeUrl)
80
+ state.homeUrl = settings.homeUrl
81
+
65
82
  loadSavedSettings(settings)
66
83
  }
67
84
 
@@ -149,5 +166,9 @@ export default {
149
166
  mode,
150
167
  blocked,
151
168
  setMode,
152
- saveSettings
169
+ saveSettings,
170
+
171
+ bookTitle,
172
+ chapterTitle,
173
+ homeUrl
153
174
  }
@@ -1,3 +1,21 @@
1
+ function initStyles(props, rootComponent) {
2
+ const settings = props.readerSettings
3
+ ? JSON.parse(props.readerSettings)
4
+ : null
5
+
6
+ if (props.cssFile) {
7
+ stylesheetLoader(props.cssFile, rootComponent)
8
+ }
9
+
10
+ if (props.cssString) {
11
+ applyStylesheet(props.cssString, rootComponent)
12
+ }
13
+
14
+ if (settings?.cssString) {
15
+ applyStylesheet(settings.cssString, rootComponent)
16
+ }
17
+ }
18
+
1
19
  function fontLoader(fontsOptions) {
2
20
  const fontsToLoad = fontsOptions.filter(item => item.link)
3
21
 
@@ -23,9 +41,7 @@ async function stylesheetLoader(stylesheet, ref) {
23
41
 
24
42
  applyStylesheet(cssText, ref)
25
43
 
26
- } catch (err) {
27
- console.log({ err })
28
- }
44
+ } catch (_) {}
29
45
  }
30
46
  }
31
47
 
@@ -37,6 +53,7 @@ async function applyStylesheet(stylesheet, ref) {
37
53
  }
38
54
 
39
55
  export default {
56
+ initStyles,
40
57
  fontLoader,
41
58
  stylesheetLoader,
42
59
  applyStylesheet
package/src/tailwind.css CHANGED
@@ -591,10 +591,6 @@ video {
591
591
  right: -0.5rem;
592
592
  }
593
593
 
594
- .-left-2 {
595
- left: -0.5rem;
596
- }
597
-
598
594
  .z-20 {
599
595
  z-index: 20;
600
596
  }
@@ -658,10 +654,6 @@ video {
658
654
  margin-bottom: 0.5rem;
659
655
  }
660
656
 
661
- .mb-5 {
662
- margin-bottom: 1.25rem;
663
- }
664
-
665
657
  .block {
666
658
  display: block;
667
659
  }
@@ -846,11 +838,6 @@ video {
846
838
  background-color: rgb(255 255 255 / var(--tw-bg-opacity));
847
839
  }
848
840
 
849
- .bg-red-700 {
850
- --tw-bg-opacity: 1;
851
- background-color: rgb(185 28 28 / var(--tw-bg-opacity));
852
- }
853
-
854
841
  .p-4 {
855
842
  padding: 1rem;
856
843
  }
@@ -863,10 +850,6 @@ video {
863
850
  padding: 0.75rem;
864
851
  }
865
852
 
866
- .p-1 {
867
- padding: 0.25rem;
868
- }
869
-
870
853
  .py-2 {
871
854
  padding-top: 0.5rem;
872
855
  padding-bottom: 0.5rem;
@@ -905,10 +888,6 @@ video {
905
888
  padding-left: 1rem;
906
889
  }
907
890
 
908
- .pt-5 {
909
- padding-top: 1.25rem;
910
- }
911
-
912
891
  .text-left {
913
892
  text-align: left;
914
893
  }
@@ -917,6 +896,11 @@ video {
917
896
  text-align: center;
918
897
  }
919
898
 
899
+ .text-sm {
900
+ font-size: 0.875rem;
901
+ line-height: 1.25rem;
902
+ }
903
+
920
904
  .text-xs {
921
905
  font-size: 0.75rem;
922
906
  line-height: 1rem;
@@ -971,14 +955,14 @@ video {
971
955
  opacity: 0;
972
956
  }
973
957
 
974
- .opacity-75 {
975
- opacity: 0.75;
976
- }
977
-
978
958
  .opacity-30 {
979
959
  opacity: 0.3;
980
960
  }
981
961
 
962
+ .opacity-75 {
963
+ opacity: 0.75;
964
+ }
965
+
982
966
  .shadow-2xl {
983
967
  --tw-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
984
968
  --tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);
@@ -1072,10 +1056,6 @@ video {
1072
1056
  right: 4rem;
1073
1057
  }
1074
1058
 
1075
- .md\:left-16 {
1076
- left: 4rem;
1077
- }
1078
-
1079
1059
  .md\:flex {
1080
1060
  display: flex;
1081
1061
  }