Skip to content

Commit

Permalink
fix(admin): 将与 breakpoint 相关代码放在 tailwind.preset.ts 中
Browse files Browse the repository at this point in the history
  • Loading branch information
caixw committed Dec 9, 2024
1 parent bcb9602 commit 786cb29
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 38 deletions.
2 changes: 1 addition & 1 deletion admin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cmfx/admin",
"version": "0.7.9",
"version": "0.7.10",
"type": "module",
"description": "适用于 cmfx 的后台管理框架",
"author": {
Expand Down
33 changes: 3 additions & 30 deletions admin/src/core/theme/breakpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,9 @@
//
// SPDX-License-Identifier: MIT

// NOTE: 此文件可能被包括非源码目录下的多个文件引用,
// 不要在此文件中引用项目专用的一些功能,比如 vite.config.ts 中的 resolve.alias 的定义等。

// 从小到大排列
export const breakpointsOrder = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'] as const;

export type Breakpoint = typeof breakpointsOrder[number];

/**
* 定义了常用的屏幕尺寸
*/
export const breakpoints: Readonly<Record<Breakpoint, string>> = {
xs: '475px',
sm: '640px',
md: '768px',
lg: '1024px',
xl: '1280px',
xxl: '1536px',
//xxxl: '1600px'
};

type BreakpointsMedia = Record<Breakpoint, string>;

/**
* 根据 {@link breakpoints} 生成的媒体查询样式
*/
export const breakpointsMedia: Readonly<BreakpointsMedia> = Object.entries(breakpoints).reduce<BreakpointsMedia>((obj, [key, val]) => {
obj[key as Breakpoint] = `(width >= ${val})`;
return obj;
}, {} as BreakpointsMedia);
import { Breakpoint, breakpointsOrder } from '../../../tailwind.preset.ts';
export { breakpoints, breakpointsMedia, breakpointsOrder } from '../../../tailwind.preset.ts';
export type { Breakpoint } from '../../../tailwind.preset.ts';

/**
* 比较两个 Breakpoint 的大小
Expand Down
30 changes: 29 additions & 1 deletion admin/tailwind.preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,35 @@
// SPDX-License-Identifier: MIT

import type { PresetsConfig, ScreensConfig } from 'tailwindcss/types/config';
import { breakpoints, breakpointsMedia } from './src/core/theme/breakpoints';

// 从小到大排列
export const breakpointsOrder = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'] as const;

export type Breakpoint = typeof breakpointsOrder[number];


/**
* 定义了常用的屏幕尺寸
*/
export const breakpoints: Readonly<Record<Breakpoint, string>> = {
xs: '475px',
sm: '640px',
md: '768px',
lg: '1024px',
xl: '1280px',
xxl: '1536px',
//xxxl: '1600px'
};

type BreakpointsMedia = Record<Breakpoint, string>;

/**
* 根据 {@link breakpoints} 生成的媒体查询样式
*/
export const breakpointsMedia: Readonly<BreakpointsMedia> = Object.entries(breakpoints).reduce<BreakpointsMedia>((obj, [key, val]) => {
obj[key as Breakpoint] = `(width >= ${val})`;
return obj;
}, {} as BreakpointsMedia);

const colors = {
'primary-bg': 'var(--primary-bg)',
Expand Down
2 changes: 1 addition & 1 deletion cmd/admin/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<html lang="cmn-Hans">
<html lang="zh-Hans">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/icon.svg" />
Expand Down
4 changes: 2 additions & 2 deletions cmd/admin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cmfx/admin-demo",
"version": "0.7.9",
"version": "0.7.10",
"type": "module",
"author": {
"name": "caixw",
Expand All @@ -22,7 +22,7 @@
},
"dependencies": {
"@solidjs/router": "^0.15.1",
"@cmfx/admin": "0.7.9",
"@cmfx/admin": "0.7.10",
"solid-js": "^1.9.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion cmd/admin/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ const o: Options = {
userMenus: current.menus()
};

await createApp('app', o);
createApp('app', o);
2 changes: 1 addition & 1 deletion cmfx/cmfx.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

// Version 表示当前框架的版本
const Version = "0.7.9"
const Version = "0.7.10"

// 400
const (
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cmfx/admin-eslint",
"version": "0.7.9",
"version": "0.7.10",
"type": "module",
"private": true,
"author": {
Expand Down

0 comments on commit 786cb29

Please sign in to comment.