使用tailwindcss

This commit is contained in:
suguo.yao 2022-10-19 15:59:50 +08:00
parent d1c1f6393a
commit 3037006490
9 changed files with 956 additions and 162 deletions

885
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -16,9 +16,13 @@
"@rushstack/eslint-patch": "^1.1.4",
"@vitejs/plugin-vue": "^3.0.3",
"@vue/eslint-config-prettier": "^7.0.0",
"autoprefixer": "^10.4.12",
"eslint": "^8.22.0",
"eslint-plugin-vue": "^9.3.0",
"postcss": "^8.4.18",
"postcss-pxtorem": "^6.0.0",
"prettier": "^2.7.1",
"tailwindcss": "^3.1.8",
"vite": "^3.0.9"
}
}

18
postcss.config.js Normal file
View File

@ -0,0 +1,18 @@
const autoprefixer = require("autoprefixer");
const tailwindcss = require("tailwindcss");
const pxtorem = require("postcss-pxtorem");
module.exports = {
plugins: [
autoprefixer(),
tailwindcss(),
pxtorem({
rootValue: 160,
propList: ["*"],
selectorBlackList: [".ignore", "keep-px"],
exclude: /(node_module)/,
minPixelValue: 1,
mediaQuery: false,
}),
],
};

View File

@ -1,55 +1,39 @@
<script setup>
import Welcome from "./components/Welcome.vue";
import TheWelcome from "./components/TheWelcome.vue";
import { inject } from "vue";
const axios = inject("axios");
console.log(axios);
import { onBeforeMount, onMounted } from "vue";
const data = {
keys: "",
};
const Search = () => {
alert(data.keys);
};
onMounted(() => {
this.$api.get('/status').then((response)=>{
console.log(response)
});
});
onBeforeMount(() => {});
</script>
<template>
<header>
<img
alt="Vue logo"
class="logo"
src="./assets/logo.svg"
width="125"
height="125"
/>
<div class="wrapper">
<Welcome msg="You did it!" />
<div class="container-none">
<div class="flex lg:flex-row md:flex-col">
<div class="basis-1/4">
<div>111111</div>
</div>
<div class="basis-3/4">
<label class="relative block">
<span class="sr-only">Search</span>
<span class="absolute inset-y-0 left-0 flex items-center pl-2">
<svg class="h-5 w-5 fill-slate-300" viewBox="0 0 20 20"></svg>
</span>
<input class="max-w-sm placeholder:italic placeholder:text-slate-400 block bg-white w-full border border-slate-300 rounded-md py-2 pl-9 pr-3 shadow-sm focus:outline-none focus:border-sky-500 focus:ring-sky-500 focus:ring-1 sm:text-sm" placeholder="Search for anything..." type="text" name="search" v-model="data.keys" v-on:keyup.enter="Search()"/>
</label>
</div>
</div>
</header>
<main>
<TheWelcome />
</main>
<div class="flex flex-row">
</div>
</div>
</template>
<style scoped>
header {
line-height: 1.5;
}
.logo {
display: block;
margin: 0 auto 2rem;
}
@media (min-width: 1024px) {
header {
display: flex;
place-items: center;
padding-right: calc(var(--section-gap) / 2);
}
.logo {
margin: 0 2rem 0 0;
}
header .wrapper {
display: flex;
place-items: flex-start;
flex-wrap: wrap;
}
}
</style>
<style scoped></style>

View File

@ -1,74 +0,0 @@
/* color palette from <https://github.com/vuejs/theme> */
:root {
--vt-c-white: #ffffff;
--vt-c-white-soft: #f8f8f8;
--vt-c-white-mute: #f2f2f2;
--vt-c-black: #181818;
--vt-c-black-soft: #222222;
--vt-c-black-mute: #282828;
--vt-c-indigo: #2c3e50;
--vt-c-divider-light-1: rgba(60, 60, 60, 0.29);
--vt-c-divider-light-2: rgba(60, 60, 60, 0.12);
--vt-c-divider-dark-1: rgba(84, 84, 84, 0.65);
--vt-c-divider-dark-2: rgba(84, 84, 84, 0.48);
--vt-c-text-light-1: var(--vt-c-indigo);
--vt-c-text-light-2: rgba(60, 60, 60, 0.66);
--vt-c-text-dark-1: var(--vt-c-white);
--vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
}
/* semantic color variables for this project */
:root {
--color-background: var(--vt-c-white);
--color-background-soft: var(--vt-c-white-soft);
--color-background-mute: var(--vt-c-white-mute);
--color-border: var(--vt-c-divider-light-2);
--color-border-hover: var(--vt-c-divider-light-1);
--color-heading: var(--vt-c-text-light-1);
--color-text: var(--vt-c-text-light-1);
--section-gap: 160px;
}
@media (prefers-color-scheme: dark) {
:root {
--color-background: var(--vt-c-black);
--color-background-soft: var(--vt-c-black-soft);
--color-background-mute: var(--vt-c-black-mute);
--color-border: var(--vt-c-divider-dark-2);
--color-border-hover: var(--vt-c-divider-dark-1);
--color-heading: var(--vt-c-text-dark-1);
--color-text: var(--vt-c-text-dark-2);
}
}
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
position: relative;
font-weight: normal;
}
body {
min-height: 100vh;
color: var(--color-text);
background: var(--color-background);
transition: color 0.5s, background-color 0.5s;
line-height: 1.6;
font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
font-size: 15px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

View File

@ -1,35 +0,0 @@
@import "./base.css";
#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
font-weight: normal;
}
a,
.green {
text-decoration: none;
color: hsla(160, 100%, 37%, 1);
transition: 0.4s;
}
@media (hover: hover) {
a:hover {
background-color: hsla(160, 100%, 37%, 0.2);
}
}
@media (min-width: 1024px) {
body {
display: flex;
place-items: center;
}
#app {
display: grid;
grid-template-columns: 1fr 1fr;
padding: 0 2rem;
}
}

4
src/main.css Normal file
View File

@ -0,0 +1,4 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

View File

@ -2,7 +2,7 @@ import { createApp } from "vue";
import App from "./App.vue";
import axios from "axios";
import "./assets/main.css";
import "./main.css";
const app = createApp(App);
const api = async (data) => {

12
tailwind.config.js Normal file
View File

@ -0,0 +1,12 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./index.html", "./src/**/*.{js,vue}"],
theme: {
extend: {},
container:{
center:true,
padding:'2rem',
}
},
plugins: [],
};