vue 看sass版本_看看不同的Sass架构

2023-11-12

vue 看sass版本

As the size and complexity of a project grows, you require some sort of logic to structure your Sass files. It helps to follow some agreed upon guidelines for creating files and folders when working in large teams and projects. Below is a review of some of the techniques in use today.

随着项目的规模和复杂性的增长,您需要某种逻辑来构造Sass文件。 在大型团队和项目中工作时,它有助于遵循一些公认的准则来创建文件和文件夹。 下面是当今使用的一些技术的回顾。

s子 (Bootstrap-sass)

Bootstrap’s intention is to be a UI library for web developers to quickly get off the ground. It is logical for them to group all variables in a single file and keep all the mixin logic hidden. Their Sass architecture mimics this idea. Each component gets its own Sass file and there’s a ./_variables.scss file, which allows you to control all the variables involved with your project.

Bootstrap的目的是成为Web开发人员可以快速起步的UI库。 对于他们来说,将所有变量分组到一个文件中并保留所有混合逻辑是合乎逻辑的。 他们的Sass体系结构模仿了这个想法。 每个组件都有自己的Sass文件,并且有一个./_variables.scss文件,该文件可让您控制项目所涉及的所有变量。

Bootstrap’s Sass architecture is unique in how it lays out its mixins. There’s a ./_mixins.scss file. This file imports all files from a mixins folder, which contains a separate file for every mixin used. Although button styles are defined in ./_buttons.scss, the mixins used for it are imported from ./_mixins.scss. This, in turn, imports the button mixins frommixins/_buttons.scss. Yo Dawg!

Bootstrap的Sass体系结构在布局其混合模块方面是独特的。 有一个./_mixins.scss文件。 该文件从mixins文件夹导入所有文件,该文件夹为每个使用的mixin包含一个单独的文件。 尽管按钮样式是在./_buttons.scss中定义的,但用于它的mixins是从./_mixins.scss中导入的。 反过来,这又从mixins/_buttons.scss导入按钮mixins。 哟道

In addition to component-level mixins, the mixin folder also contains global mixins such as mixins/_border-radius.scss and mixins/_responsive-visibility.scss. Although bootstrap’s mixins are not overly complex, this architecture is better suited for a project where the mixins are really complex and require that they be broken down into smaller bits. Or in cases where you want to keep that logic hidden from visual styles of components. In conclusion, this architecture works best for Bootstrap but might not work for your sass project.

除了组件级的mixin外,mixin文件夹还包含全局mixin,例如mixins/_border-radius.scssmixins/_responsive-visibility.scss 。 尽管bootstrap的mixin不太复杂,但是此体系结构更适合于mixin 确实很复杂并且要求将它们分解成更小的位的项目。 或者,如果您想使逻辑隐藏在组件的可视样式中。 总之,此体系结构最适合Bootstrap,但可能不适用于您的 sass项目。

Here’s how the folder structure looks:

文件夹结构的外观如下:

bootstrap/
|– bootstrap.scss   # Manifest file 
|– _alerts.scss     # Component file 
|– _buttons.scss    # Component file 
|– _mixins.scss     # Mixin file – imports all files from mixins folder
|–  ...             # Etc..
|– mixins/
|  |–  _alerts.scss # Alert mixin
|  |– _buttons.scss # Button mixin
|  |– ...           # Etc..

祖尔布基金会 (Zurb Foundation)

Foundation has a well thought out Sass architecture and it works beautifully for customizing, which is one of its biggest strengths. There’s a settings.scss at root level, which allows you to override any variable used for building components. However, each component file contains variables specific to that component.

Foundation具有经过深思熟虑的Sass架构,并且可以很好地进行自定义,这是其最大的优势之一。 在根级别有一个settings.scss ,它允许您覆盖用于构建组件的任何变量。 但是,每个组件文件都包含特定于该组件的变量。

Foundation also abstracts functions used in the project in a separate functions.scss file. This is good because these functions are framework specific and you should not be editing this file.

Foundation还会在单独的functions.scss文件中抽象化项目中使用的functions.scss 。 这很好,因为这些功能是特定于框架的,因此您不应编辑此文件。

All global mixins such as border radius and transition effects are available in components/_global.scss. They are logically structured as follows:

所有全局混合(例如边界半径和过渡效果)都可以在components/_global.scss 。 它们的逻辑结构如下:

- Import - global mixins
 - Component specific variables (`$button-tny`, `$button-margin-bottom`) 
 - Component specific mixins
 - Extends - (not the @extend but actual style definitions, where mixins are called)

All component-specific variables are defined as !default, so that they can be overridden using the _settings.scss. If you prefer to keep it simple, you can just change the variables in _settings.scss and call it a day. If you feel more adventurous, you could play with component-specific variables and easily be able to change how your components look.

所有特定于组件的变量都定义为!default ,因此可以使用_settings.scss覆盖它们。 如果您希望保持简单,可以只更改_settings.scss的变量并将其命名为day。 如果您喜欢冒险,可以使用特定于组件的变量,并可以轻松更改组件的外观。

Since their components are built out of mixins and variables, it allows for maximum flexibility. A lot of sites built using Foundation don’t end up looking the same.

由于它们的组件是由mixin和变量构建的,因此可以提供最大的灵活性。 许多使用Foundation构建的网站最终看起来都不一样。

You can adopt foundation’s Sass architecture for most small to medium websites. It becomes very easy to get into the scope of any component and have all required variables, mixins, and extends within the same file.

您可以为大多数中小型网站采用Foundation的Sass架构。 进入任何组件的范围并在同一文件中拥有所有必需的变量,mixins和扩展变得非常容易。

Here’s how the folder structure looks:

文件夹结构的外观如下:

foundation/
|– foundation.scss           # Manifest file 
|– foundation 
|  |– _functions.scss        # Library specific functions 
|  |– _settings.scss         # Change variables for the entire project
|  |– components
|  |  |– _buttons.scss       # Component file (will import _globals.scss)
|  |  |– _globals.scss       # Global mixins
|  |  |– _alerts.scss        # Component file (will import _globals.scss)

戴尔·桑德(Dale Sande)的建筑 (Dale Sande’s Architecture)

Dale Sande, in his presentation “Clean out your Sass Junk-Drawer”, recommends a modular approach to organizing your Sass files. This comes in handy in enterprise-level projects where the number and visual complexity of modules can be pretty high. This approach helps retain all logic related to a module within its own folder, which allows sub-modules to extend and reuse styles in a scoped fashion. It can also be useful in small to medium projects, if you prefer separating presentation from Sass logic in your files.

戴尔·桑德(Dale Sande)在他的演讲“清理Sass垃圾抽屉”中,建议了一种模块化方法来组织Sass文件。 这在企业级项目中非常有用,在这些项目中,模块的数量和视觉复杂性可能很高。 这种方法有助于将与模块相关的所有逻辑保留在其自己的文件夹中,这允许子模块以范围限定的方式扩展和重用样式。 如果您更喜欢在文件中将表示形式与Sass逻辑分开,则它在中小型项目中也很有用。

One of the major advantages to following Dale Sande’s approach is the fact that it makes it easy to create a separate stylesheet for a particular module. Inside your project, you could load one base stylesheet that contains global styles and load another stylesheet specific to the module. This helps remove a lot of bloat from the code, improving performance and load speed.

遵循Dale Sande的方法的主要优点之一是,可以很容易地为特定模块创建单独的样式表。 在项目内部,您可以加载一个包含全局样式的基本样式表,并加载特定于该模块的另一样式表。 这有助于消除代码中的大量膨胀,从而提高性能和加载速度。

Here’s the folder structure:

这是文件夹结构:

sass/
|– style.scss                        # Manifest
|– modules/ 
|  |– registration/                  # Sub Module
|  |  |–  _extends.scss              # Functional 
|  |  |–  _functions.scss            # Functional 
|  |  |–  _mixin.scss                # Functional  
|  |  |–  _module_registration.scss  # Imports functional partials and contains presentational 
|  |  |–  _module_personalInfo.scss  # Imports functional partials

样式原型 (Style Prototypes)

Style prototypes, by Sam Richard, is a brilliant tool and set of guidelines for design in the browser using Sass and Compass. In this architecture, components are logically grouped under specific folders such as base, components, layouts (SMACSS) or atoms, molecules, and components (atomic design).

萨姆·理查德(Sam Richard)编写的风格原型是一个出色的工具,也是使用Sass和Compass在浏览器中进行设计的一套准则。 在此体系结构中,组件在逻辑上分组在特定的文件夹下,例如基础,组件,布局(SMACSS)或原子,分子和组件( 原子设计 )。

Further, each component gets its own set of partials: _variables.scss, _mixins.scss, _extends.scss and a manifest file (_buttons.scss, _alerts.scss etc).

此外,每个组件都有自己的部分集: _variables.scss_mixins.scss_extends.scss和清单文件( _buttons.scss_alerts.scss等)。

This approach has a couple of disadvantages though:

但是,这种方法有两个缺点:

  1. Compile time – More files require more time to get compiled

    编译时间–更多文件需要更多时间来进行编译
  2. It might require a lot of file switching when you build components initially. But once you are done, its a breeze to maintain or make changes.

    最初构建组件时,可能需要大量文件切换。 但是一旦完成,维护或进行更改就变得轻而易举。

The benefit here is the ability to work on a single portion of a module. It clearly demarcates configuration (variables), functional (mixins, extends), and presentational (component partials) portions used to design a component. Global configurations are kept separate from component/module level configuration.

这样做的好处是可以在模块的单个部分上工作。 它清楚地划分了用于设计组件的配置 (变量), 功能 (mixin,扩展)和外观 (组件局部)部分。 全局配置与组件/模块级别的配置保持分开。

This separation helps maintain sanity in medium to large projects, where you have multiple teams working on modules. It also becomes easier to create module specific stylesheets, when required.

这种分离有助于在大型项目中保持理智,在该项目中,您需要多个团队来处理模块。 在需要时,创建模块特定的样式表也变得更加容易。

Here’s the folder structure:

这是文件夹结构:

scss/
|– style.scss    # Manifest
|– partials/
|  |– base/
|  |  |– _content.scss
|  |  |– content
|  |  |  |– _variables.scss    # Component specific variables  
|  |  |  |– _extends.scss      # Component specific extends
|  |  |  |– _mixins.scss       # Component specific mixins
|  |– components/
|  |  |– _message.scss
|  |  |– message
|  |  |  |– _variables.scss
|  |  |  |– _extends.scss
|  |  |  |– _mixins.scss
|  |– global/
|  |  |– _variables.scss
|  |  |– _extends.scss
|  |  |– _mixins.scss
|  |  |– _functions.scss
|  |– layouts/
|  |  |– _article.scss
|  |  |– article
|  |  |  |– _variables.scss
|  |  |  |– _extends.scss
|  |  |  |– _mixins.scss

SMACSS (SMACSS)

I think Hugo does a great job of covering a SMACSS-based approach, which you can read about in his Sass architecture post, so I won’t discuss that here. There’s also a handy SMACSS starter kit by Mina Markham available.

我认为Hugo在涵盖基于SMACSS的方法方面做得很好,您可以在他的Sass体系结构文章中了解到这一点,因此在此不做讨论。 还有Mina Markham提供的方便的SMACSS入门工具包

结论 (Conclusion)

In this article, we looked at different ways to structure your Sass files. To decide which method to use, you need to weigh your options between complexity, compile time, and personal preference.

在本文中,我们研究了构建Sass文件的不同方法。 要决定使用哪种方法,您需要权衡复杂性,编译时间和个人喜好之间的选择。

This becomes tricky when working on teams. Make sure everyone feels comfortable with your approach and feel free to tweak methodologies to suit your specific circumstances.

在团队中工作时,这变得棘手。 确保每个人都对您的方法感到满意,并随意调整方法以适合您的特定情况。

I like the Style Prototypes architecture best because it suits the way I think. The important thing to note is

我最喜欢样式原型架构,因为它适合我的想法。 需要注意的重要一点是

The deeper you nest, the longer it takes to compile.

嵌套的深度越深,编译时间就越长。

Do let us know your project’s Sass architecture in the comments section.

请在评论部分让我们知道您项目的Sass架构。

翻译自: https://www.sitepoint.com/look-different-sass-architectures/

vue 看sass版本

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

vue 看sass版本_看看不同的Sass架构 的相关文章

  • 使用 Pytest 捕获 SystemExit 消息

    我正在使用 pytest 编写测试 我遇到了一些函数抛出异常的情况SystemExit如果输入错误 终端上会显示一些错误消息 我想为以下情况编写测试SystemExit抛出并验证输出错误消息中是否有特定字符串 这是代码 def test v
  • 使用存储的密钥作为环境变量

    我有一个秘密密钥存储在 GCP 的秘密管理器中 我们的想法是使用该密钥通过云功能获取预算列表 现在 我可以从代码中访问该密钥 但我面临的问题是我需要使用该密钥设置一个环境变量 这是我添加密钥的方式 如果您的本地目录中有该文件 但是还有其他方
  • 如何提高 Guice 启动时的性能

    好吧 我知道我的计算不客观等等 但无论如何 我讨厌在执行单元测试时等待这么多时间 我的 guice swing 应用程序需要大约 7 秒来初始化 这是一个简单的 IRC 客户端 在那一刻 没有打开连接 我什至还没有调用任何 java io
  • 按位非运算符

    为什么要按位运算 0 打印 1 在二进制中 不是0应该是1 为什么 你实际上很接近 在二进制中 不是0应该是1 是的 当我们谈论一位时 这是绝对正确的 然而 一个int其值为0的实际上是32位全零 将所有 32 个 0 反转为 32 个 1
  • 如何在 django 中发出 post 请求后获取表单的名称?

  • SOAP Web 服务中的用户身份验证

    我提出了一个关于JAX WS 身份验证和授权 如何 https stackoverflow com questions 5314782 jax ws authentication and authorization how to 讨论了安全
  • 在Java中一个接一个地播放WAV文件

    我正在尝试玩几个WAV http en wikipedia org wiki WAV文件一个接一个 我尝试了这个方法 for String file audioFiles new AePlayWave file start 但这会同时播放它
  • JFreeChart MeterPlot

    我目前正在用java做Agent项目 在某些时候 我需要显示一个仪表 例如 电池电量 我的程序中有 5 个代理 每个代理都会创建自己的带有名称的仪表图 但不知何故他们没有更新数据集 或者他们正在更新数据集 只是它没有显示在仪表图上 任何想法
  • 如何更改Python中的全局变量[重复]

    这个问题在这里已经有答案了 我正在尝试更改程序中的变量 我在程序开始时声明了一个全局变量 我想在程序中的不同函数中更改该变量 我可以通过再次声明函数内的变量来做到这一点 但我想知道是否有更好的方法来做到这一点 下面是一些测试代码来解释我的意
  • ObservableList 不更新 ArrayList

    对于学校作业 我们正在使用 JavaFX 中的 ObservableList 对象 对吗 我已经为此工作了一天多了 但无法弄清楚 老师只告诉我们 谷歌一下 所以这也没有帮助 基本上 我们正在开发一个基本的管理应用程序来跟踪人们及其家人 人们
  • 无法从 celery 信号连接到 celery 任务?

    我正在尝试连接task2 from task success signal from celery signals import task success from celery import Celery app Celery app t
  • 对于每个抛出异常的语句,try/catch 是否被视为反模式?

    我目前正在审查同事的 Java 代码 我看到很多情况下 每个可能抛出异常的语句都被封装在自己的 try catch 中 其中 catch 块都执行相同的操作 哪个操作与我的问题无关 对我来说 这似乎是一种代码味道 我记得读到过它是一种常见的
  • 如何将我的自定义相机应用程序设置为默认应用程序?

    如果我使用以下代码 Intent takePictureIntent new Intent MediaStore ACTION IMAGE CAPTURE startActivityForResult takePictureIntent 1
  • 连接 Flask Socket.IO Server 和 Flutter

    基本上 我有一个套接字 io 烧瓶代码 import cv2 import numpy as np from flask import Flask render template from flask socketio import Soc
  • 无法使用 Python 3 编写的 gzip.open() 将压缩文件上传到云存储

    当我尝试在 Cloud Shell 实例上使用 python 脚本将压缩的 gzip 文件上传到云存储时 它总是上传一个空文件 这是重现错误的代码 import gzip from google cloud import storage s
  • 仅在java中使用数组计算50的阶乘

    我是java的初学者 我有一个作业要编写一个完整的程序 使用数组计算 50 的阶乘 我无法使用像 biginteger 这样的任何方法 我只能使用数组 因为我的教授希望我们理解背后的逻辑 我猜 然而 他并没有真正教我们数组的细节 所以我在这
  • 使用 Python PuLP 混合整数规划的时间限制

    我一直在使用PuLP http pythonhosted org PuLP 解决我感兴趣的特定混合整数线性规划 MIP 但是 随着问题规模的增长 PuLP 花费的时间太长 我希望能够运行求解器一段时间 并在需要很长时间的情况下提前终止它 并
  • Spring Boot 健康执行器 - 什么时候上线?

    我找不到任何有关 Springs Health Actuator 何时返回 UP 状态的文档 你能依靠一切吗 Components正在初始化 会不会 Controller准备好满足请求了吗 为了测试应用程序上下文是否已加载 您可以执行此自定
  • 当我必须在 Netty4 编码器中调用 ByteBuf.retain() 时?

    我正在编写一个以 NUL 终止 JSON 消息的编码器 以便在消息碎片的情况下可以对其进行解码 我找到了这个样本 gt click https github com netty netty blob master codec src mai
  • Pepper Robot:如何将 Python 地标检测移植到 Choregraphe?

    我正在尝试编写一个小程序 让 Pepper 通过 Choregraphe 检查房间内的地标 用于地标检测的常规 Python 代码工作得很好 但我无法将其移植到 Choregraphe http doc aldebaran com 2 5

随机推荐

  • 【GRE】GRE普通考试改革前后区别

    参考张禄老师的视频 首先是官网的总结 从图中看出的几个点 写作 由 argument issue 改为 issue 删除 argument 这意味着写作想获得高分将更加困难 因为大陆考生基本都是靠 argument 拉分的 数学和语文 题量
  • 谈谈我的个人追求

    说到个人追求 我发现我自己都无法说出来 是我没有答案 还是不敢去追求呢 是我的心太浮 要的太多吧 反正这个问题也不是几分钟的思考就可以得到的答案 这个问题 或许需要我一辈子的努力去寻找 见识的东西太少了 视野过于狭隘 愿努力之 看到更大的世
  • 三、MySql 数据类型

    文章标题 Mysql数据类型 Int 类型 INT N 是什么 字符类型 排序规则 时间类型 前文 mysql权限 Mysql数据类型 Int 类型 有无符号 在项目中使用 BIGINT 而且是有符号的 演示 create table te
  • 网络编程——IO模型

    搭建select的TCP客户端 include
  • 100流明相当于多少w_20年前的100元,相当于现在的多少钱?说出来你可能不信

    最近 有网友提出一个问题 他说20年前的100元 相当于现在的多少钱 对此 专家们回答是 2000年我国GDP总量为1 2万亿美元 位居全球第六 到2019年 我国GDP已经高达14 3万亿美元 位居全球第二位 20年时间GDP增长了11
  • 汇编符号语言

    CSDN话题挑战赛第1期 活动详情地址 第1期话题PK赛 参赛话题 汇编知识分享 话题描述 我们的计算机知识就像一座金字塔 底层是数学 上面是数字电路 然后是汇编 再往上是操作系统 网络 数据库 高级编程语言 框架等等 我们不可能精通这个金
  • 前端项目uniapp小兔鲜儿微信小程序项目

    小兔鲜儿 项目起步 项目架构 项目架构图 拉取项目模板代码 项目模板包含 目录结构 项目素材 代码风格 模板地址 git clone http git itcast cn heimaqianduan erabbit uni app vue3
  • 由于找不到msvcp100.dll无法继续执行代码怎么解决

    当遇到程序无法正常运行 提示缺少msvcp100 dll文件时 最初的反应可能是困惑和不知所措 然而 通过修复msvcp100 dll文件 我发现这个问题实际上并不复杂 并且可以通过一些简单的步骤解决 在修复msvcp100 dll文件的时
  • k8s集群部署

    文章目录 1 二进制部署三节点 复用 高可用 k8s 集群 1 1 环境规划阶段 1 1 1 实验架构图 1 1 2 系统版本说明 1 1 3 环境基本信息 1 1 4 k8s 网段划分 1 2 基础安装及优化阶段 1 2 1 系统信息检查
  • mmsegmentation安装教程

    本文是基于Annconda下的安装教程 先要把Annconda安装好 安装好之后打开anaconda prompt控制面板 换成清华源 pip config set global index url https pypi tuna tsin
  • Python 第三方模块 绘图 Seaborn模块2

    四 可视化数据集的分布 1 直方图
  • linux打开网络摄像头失败,Opencv没有检测到linux上的firewire网络摄像头

    我通过firewire连接了一个凸轮 并尝试使用opencv访问它 相机在香菜中被检测到并且能够获得视频流 以下是我使用的代码 include home iiith opencv 2 4 9 include opencv cv h incl
  • JAVA循环使每次循环出来的都是四位数例如0001,0002,0003 三种实现方式

    问题描述 循环使每次循环出来的都是四位数例如0001 0002 0003 现在给出三种实现方式 第一种实现方式 public class temp1 public static void main String args for int i
  • enum枚举变量的用法

    Class Piece public typedef enum colorless white black pieceColor enum pieceColor colorless white black 首先声明一种枚举型变量 该变量的类
  • GB/T28181-2022针对H.265、AAC的说明和技术实现

    GB T28181 2022规范说明 GB T28181 2022相对来GB T28181 2016针对H 265 AAC的更新如下 更改了 联网系统通信协议结构图 媒体流通道增加了 H 265 G 722 1 AAC 见 4 3 1 20
  • 为Linux安装软件包时后面标注的arm,aarch到底是什么玩意儿以二进制安装docker-compose为例

    引言 装docker compose装不上 去github找二进制 看到这些版本人傻了 记录一下 如何确定自己的服务器应该安装哪个 Arch命令 arch 这个最简单 直接输出架构方式 aarch64 就是 ARM 架构 x86 64 就是
  • Spring注解家族介绍:@RestController

    前言 Spring Boot可以说是当前JAVA最为重要的一个框架 而Spring Boot的基石Spring中有着丰富的注解 因此我们会利用几篇文章来讲解我目前学到的各种注解 因此本类型文章的篇幅会比较短 主要着重于介绍各个注解 目录 前
  • GitHub十大Python项目推荐,Star最高26.4k

    编写 Python 代码的乐趣应该是看到简短 简洁 易读的类 这些类用少量清晰的代码来执行大量的操作 而不是那些让读者厌烦的大量琐碎代码 在相当长的一段时间内 世界各地的开发人员在他们的大多数项目中都倾向于使用 Python 编程语言的易用
  • C语言习题

    1 输入一个正整数 输出其逆数 例如输入12345 输出应为54321 2 计算1 2 3 n的值 n是从键盘输入的自然数 3 从终端 键盘 读入20个数据到数组中 统计其中正数的个数 并计算这些正数之和 4 从终端 键盘 将5个整数输入到
  • vue 看sass版本_看看不同的Sass架构

    vue 看sass版本 As the size and complexity of a project grows you require some sort of logic to structure your Sass files It