Skip to content

Commit 5e77a43

Browse files
committed
improve compass stylings and readout info
1 parent 1426d2d commit 5e77a43

File tree

2 files changed

+101
-52
lines changed

2 files changed

+101
-52
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "vue-breakpoint-compass",
3-
"version": "0.4.4",
3+
"version": "1.0.0",
44
"description": "An easy to use plugin that makes responsive design with css breakpoints even easier.",
55
"main": "dist/index.js",
66
"private": false,
77
"license": "MIT",
88
"types": "dist/index.d.ts",
99
"peerDependencies": {
10-
"vue": "^3.2.20"
10+
"vue": "^3.0.0"
1111
},
1212
"repository": {
1313
"type": "git",

src/components/BreakpointCompass.vue

Lines changed: 99 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,76 +2,121 @@
22
<div id="breakpointcompass" :style="styleObject">
33
<div
44
id="breakpointcompass_display"
5-
style="color: black; display: flex; flex-direction: column; height: auto"
5+
style="
6+
color: black;
7+
display: flex;
8+
flex-direction: column;
9+
height: auto;
10+
padding: 2px;
11+
"
612
>
713
<div
814
style="
915
display: flex;
1016
flex-direction: row;
11-
justify-content: space-between;
17+
justify-content: space-evenly;
18+
padding: 3px;
1219
"
1320
>
14-
<p
15-
style="padding: 2px 1px; font-size: 4px; text-align: right"
16-
v-show="prevBP !== NameFromPixels(width)"
17-
>
18-
{{ prevBP }}
19-
</p>
20-
<p style="padding: 2px 1px; font-size: 16px">
21+
<p style="font-size: 20px; margin: 0; padding: 2px">
2122
{{ NameFromPixels(width) }}
2223
</p>
23-
<p
24-
style="padding: 2px 1px; font-size: 4px; text-align: right"
25-
v-show="nextBP !== NameFromPixels(width)"
26-
>
27-
{{ nextBP }}
28-
</p>
24+
🧭
25+
<p style="font-size: 20px; margin: 0; padding: 2px">{{ width }}</p>
2926
</div>
3027
<div
3128
style="
3229
display: flex;
3330
flex-direction: row;
3431
justify-content: space-between;
3532
"
33+
></div>
34+
<div
35+
style="
36+
width: full;
37+
height: 25px;
38+
border-left: 2px solid red;
39+
border-right: 2px solid red;
40+
background-color: skyblue;
41+
42+
position: relative;
43+
"
44+
id="breakpointcompass_progresscontainer"
3645
>
3746
<p
38-
style="padding: 2px 1px font-size: 4px; text-align:right;"
39-
v-show="prevPx !== width"
47+
style="
48+
font-size: 10px;
49+
margin: 0;
50+
color: red;
51+
position: absolute;
52+
top: 1px;
53+
left: 1px;
54+
font-weight: 300;
55+
"
56+
v-show="prevBP != 'none'"
4057
>
41-
{{ prevPx }}
58+
&lt; {{ prevBP }}
4259
</p>
43-
<p style="padding: 2px 1px">{{ width }}</p>
4460
<p
45-
style="padding: 2px 1px; text-align: right"
46-
v-show="nextBP !== NameFromPixels(width)"
61+
style="
62+
font-size: 10px;
63+
color: red;
64+
position: absolute;
65+
bottom: 1px;
66+
margin: 0;
67+
left: 1px;
68+
font-weight: 300;
69+
"
70+
v-show="prevPx !== width && prevPx !== 0"
4771
>
48-
{{ nextPx }}
72+
{{ prevPx }}
4973
</p>
74+
75+
<div
76+
class="font-weight: 100; color: red; position: absolute; right 2px; bottom: 2px; display: flex; flex-direction: column;"
77+
>
78+
<p
79+
style="
80+
font-size: 10px;
81+
color: red;
82+
margin: 0;
83+
position: absolute;
84+
top: 1px;
85+
right: 1px;
86+
font-weight: 300;
87+
"
88+
v-show="nextBP != NameFromPixels(width)"
89+
>
90+
{{ nextBP }} >
91+
</p>
92+
<p
93+
style="
94+
font-size: 10px;
95+
margin: 0;
96+
color: red;
97+
position: absolute;
98+
bottom: 1px;
99+
right: 1px;
100+
font-weight: 300;
101+
"
102+
v-show="nextBP != NameFromPixels(width)"
103+
>
104+
{{ nextPx }}
105+
</p>
106+
</div>
107+
<div
108+
id="breakpointcompass_progressbar"
109+
style="
110+
background-color: #ff0000bb;
111+
height: 100%;
112+
width: 3px;
113+
position: absolute;
114+
top: 0px;
115+
"
116+
:style="{ left: progressNext.toString() + '%' }"
117+
></div>
50118
</div>
51119
</div>
52-
<div
53-
style="
54-
width: full;
55-
height: 20px;
56-
border-style: solid;
57-
border-width: 2px;
58-
border-color: gold;
59-
position: relative;
60-
"
61-
id="breakpointcompass_progresscontainer"
62-
>
63-
<div
64-
id="breakpointcompass_progressbar"
65-
style="
66-
background-color: #ff0000bb;
67-
height: 100%;
68-
width: 3px;
69-
position: absolute;
70-
top: 0px;
71-
"
72-
:style="{ left: progressNext.toString() + '%' }"
73-
></div>
74-
</div>
75120
</div>
76121
</template>
77122

@@ -92,18 +137,19 @@ const styleObject: CSSProperties = {
92137
bottom: injected?.position?.includes("b") ? "30px" : "",
93138
right: injected?.position?.includes("r") ? "30px" : "",
94139
left: injected?.position?.includes("l") ? "30px" : "",
95-
minWidth: "90px",
140+
minWidth: "110px",
96141
width: "auto",
97142
borderStyle: "solid",
98143
borderWidth: "2px",
99144
borderColor: "goldenrod",
100145
height: "auto",
101146
textAlign: "center",
102-
fontSize: "6px",
147+
fontSize: "12px",
103148
fontWeight: "bold",
104149
backgroundColor: "gold",
105150
display: "flex",
106151
flexDirection: "column",
152+
borderRadius: "5px",
107153
};
108154
109155
//default breakpoints in case of problem with inject ( from tailwind v3)
@@ -153,11 +199,11 @@ const prev = (c: String): Number => {
153199
const { width } = useWindowSize();
154200
155201
const nextBP = computed((): String => {
156-
return NameFromPixels(Number(nextPx));
202+
return NameFromPixels(next(NameFromPixels(width.value)));
157203
});
158204
159205
const prevBP = computed((): String => {
160-
return NameFromPixels(Number(prevPx) - 5);
206+
return NameFromPixels(Number(prev(NameFromPixels(width.value))) - 2);
161207
});
162208
163209
const nextPx = computed((): Number => {
@@ -178,7 +224,10 @@ const progressNext = computed((): Number => {
178224
}
179225
// return the percentage toward the next breakpoint
180226
return Math.round(
181-
((width.value - Number(prevPx)) / (Number(nextPx) - Number(prevPx))) * 100
227+
((width.value - Number(prev(NameFromPixels(width.value)))) /
228+
(Number(next(NameFromPixels(width.value))) -
229+
Number(prev(NameFromPixels(width.value))))) *
230+
100
182231
);
183232
});
184233
</script>

0 commit comments

Comments
 (0)