项目作者: phpfyi

项目描述 :
FX - CSS Framework
高级语言: CSS
项目地址: git://github.com/phpfyi/fx.git
创建时间: 2019-10-02T00:19:57Z
项目社区:https://github.com/phpfyi/fx

开源协议:

下载


FX - CSS Framework

FX is a lightweight SCSS framework with a grid system and set of utility classes for rapidly building UI’s

Code Language
Code Size
Commit Activity
Latest Commit

Installation

NPM

Add the FX framework as a dev dependency

  1. npm i https://github.com/phpfyi/fx --save-dev

Copy the FX core files into your local SASS folder (adjust the destination to suit your project)

  1. cp -R node_modules/fx/src/core src/assets/scss

Composer

Require the FX framework package via composer.

  1. composer require phpfyi/fx

Copy the FX core files into your local SASS folder (adjust the destination to suit your project)

  1. cp -R vendor/phpfyi/fx/src/core src/assets/scss

Generated files

After running the cp command a number of files and folders are generated

  • app.scss - main app SCSS file
  • _config.scss - var configuration file
  • _mixins.scss - mixin imports files
  • app/ - app imports
  • mixins/ - app mixins

_config.scss File

The _config.scss file is used both in FX SCSS files and you app SCSS files to create things like the grid system and default styles.

  1. ////////////////////////////////////////////////////////////////////////////////
  2. // GRID
  3. ////////////////////////////////////////////////////////////////////////////////
  4. $breakpoints: (
  5. "": 0px,
  6. "-xs": 480px,
  7. "-s": 600px,
  8. "-m": 768px,
  9. "-l": 960px,
  10. "-xl": 1200px,
  11. "-xxl": 1360px,
  12. );
  13. $columns: 12;
  14. $container-max: 1220px;
  15. ////////////////////////////////////////////////////////////////////////////////
  16. // FONT
  17. ////////////////////////////////////////////////////////////////////////////////
  18. $font-heading: "Lato", sans-serif;
  19. $font-body: "Lato", sans-serif;
  20. $font-code: monospace;
  21. $font-family: $font-body;
  22. $font-size: 18px;
  23. $font-weight: 400;
  24. $line-height: 28px;
  25. $font-weights: (300, 400, 500, 600, 700);
  26. ////////////////////////////////////////////////////////////////////////////////
  27. // COLORS
  28. ////////////////////////////////////////////////////////////////////////////////
  29. $colors: (
  30. "black": #000,
  31. "white": #fff,
  32. "grey-xxl": #F7F7F7,
  33. "grey-xl": #ececec,
  34. "grey-l": #CCC,
  35. "grey-m": #999,
  36. "grey-d": #666,
  37. "grey-xd": #333,
  38. "grey-xxd": #232323,
  39. "grey-xxxd": #171717,
  40. );
  41. ////////////////////////////////////////////////////////////////////////////////
  42. // IMAGES
  43. ////////////////////////////////////////////////////////////////////////////////
  44. $img: "/img/";
  45. ////////////////////////////////////////////////////////////////////////////////
  46. // BOX
  47. ////////////////////////////////////////////////////////////////////////////////
  48. $padding: (0, 5, 10, 15, 20, 25, 30, 40, 50);
  49. $margins: (0, 5, 10, 15, 20, 25);
  50. $widths: (0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100);
  51. $heights: (0, 20, 40, 60, 80, 100);
  52. ////////////////////////////////////////////////////////////////////////////////
  53. // POSITION
  54. ////////////////////////////////////////////////////////////////////////////////
  55. $z-indexes: (0, 1, 2, 3, 4, 5);

app.scss File

The app.scss file is created with the following imports. These provide a CSS reset, access to the FX utility classes, and a scaffold to quickly customize key CSS styling.

  1. // fx
  2. @import "~fx/src/reset";
  3. @import "~fx/src/utilities";
  4. // app
  5. @import "app/body";
  6. @import "app/card";
  7. @import "app/code";
  8. @import "app/form";
  9. @import "app/heading";
  10. @import "app/hr";
  11. @import "app/_input-button";
  12. @import "app/_input-checkbox";
  13. @import "app/_input-radio";
  14. @import "app/_input-select";
  15. @import "app/_input-textarea";
  16. @import "app/_input";
  17. @import "app/_label";
  18. @import "app/link";
  19. @import "app/list";
  20. @import "app/paragraph";
  21. @import "app/table";
  22. @import "app/text";

Importing Global Styles

FX requires 4 files to be loaded globally before any other SCSS. Your application configuration and mixins (generated from the cp command above), and the FX functions and mixins.

Manually

You can import these manually if required.

  1. @import "@/assets/scss/_config.scss";
  2. @import "@/assets/scss/_mixins.scss";
  3. @import "~fx/src/_functions.scss";
  4. @import "~fx/src/_mixins.scss";

Vue

If using Vue you can add the following to vue.config.js

  1. module.exports = {
  2. css: {
  3. loaderOptions: {
  4. sass: {
  5. additionalData: `
  6. @import "@/assets/scss/_config.scss";
  7. @import "@/assets/scss/_mixins.scss";
  8. @import "~fx/src/_functions.scss";
  9. @import "~fx/src/_mixins.scss";
  10. `,
  11. },
  12. },
  13. },
  14. }

FX Mixins

FX provides handy mixins to streamline workflow and cut out a lot of boilerplate code. A number of these mixins will add required cross browser prefixes as well as validate passed values against your configuration. e.g colors are present in the $colors array.

See src/mixins/ for all the mixins files

  1. @mixin animation($value)
  2. @mixin appearance($value: none)
  3. @mixin bg-color($color)
  4. @mixin bg-opacity($color)
  5. @mixin border-radius($size)
  6. @mixin box-shadow($x: 0, $y: 0, $blur: 2px, $color: #666)
  7. @mixin box-sizing($value: border-box)
  8. @mixin button
  9. @mixin color($color)
  10. @mixin flex
  11. @mixin gradient-v($from: 0%, $start: '#FFF', $to: 100%, $stop: #000)
  12. @mixin hover-underline
  13. @mixin indent-hidden
  14. @mixin input
  15. @mixin keyframes($name)
  16. @mixin min-width($breakpoint: "")
  17. @mixin position($position: absolute, $z-index: 0, $top: auto, $right: auto, $bottom: auto, $left: auto)
  18. @mixin position-relative($z-index: 0, $top: auto, $right: auto, $bottom: auto, $left: auto)
  19. @mixin position-fixed($z-index: 0, $top: auto, $right: auto, $bottom: auto, $left: auto)
  20. @mixin position-absolute($z-index: 0, $top: auto, $right: auto, $bottom: auto, $left: auto)
  21. @mixin prefix($key, $value)
  22. @mixin rotate($degrees)
  23. @mixin scroll-x
  24. @mixin scroll-y
  25. @mixin square($size)
  26. @mixin circle($size)
  27. @mixin transform($value)
  28. @mixin transition($property: all, $time: 500ms, $method: ease-in-out)

FX Utilities

The utility classes allow you to quickly style elements without having to add a lot of custom classes and selectors.

See src/utilities/ for all the utility files

  1. .align-h // align horizontal
  2. .box-shadow // add box shadow
  3. .cl // clear left
  4. .cr // clear right
  5. .cb // clear both
  6. .ca // clear after
  7. .col-12 // columns
  8. .col-12-m // columns at breakpoint
  9. .container // container
  10. .container-s // container max-width is breakpoint
  11. .block // display block
  12. .inline // display inline
  13. .inline-block // display inline-block
  14. .hide // display none
  15. .flex-items-c // align inner items center
  16. .flex-items-h // align inner items horizontal
  17. .flex-items-v // align inner items vertical
  18. .flex-items-end // align inner items to end
  19. .flex-reverse // reverse direction
  20. .flex-reverse-m // reverse direction at breakpoint
  21. .flex-fill // flex 1
  22. .flex-grow // flex grow
  23. .flex-shrink // dont't stretch
  24. .flex-column // flex direction column
  25. .flex // display flex
  26. .flex-m // display flex at breakpoint
  27. .fl // float left
  28. .fr // float right
  29. .font-body // $font-body style
  30. .font-heading // $font-heading style
  31. .font-code // $font-code style
  32. .font-uppercase // uppercase text
  33. .font-italic // italic text
  34. .font-600 // font weight
  35. .img-stretch // file height and width
  36. .mm // 10px margin
  37. .mar-10 // margin by size
  38. .mar-10-h // horizontal margin by size
  39. .mar-10-v // vertical margin by size
  40. .overflow-hidden // hide overflow
  41. .pp // 10px padding
  42. .pad-10 // padding by size
  43. .pad-10-h // horizontal padding by size
  44. .pad-10-v // vertical padding by size
  45. .relative // relative position
  46. .absolute // absolute position
  47. .absolute-c // absolute position and centered
  48. .absolute-v // absolute position and centered vertically
  49. .h-100 // height by percent
  50. .vh-100 // vertical height by percent
  51. .w-100 // width by percent
  52. .color-grey-l // color from $colors config
  53. .bg-grey-l // background color from $colors config
  54. .txt-c // center aligned text
  55. .txt-l // left aligned text
  56. .txt-r // right aligned text
  57. .underline-hover // underline on hover
  58. .underline-none // remove text decoration
  59. .invisible // visibility hidden
  60. .visible // visibility visible
  61. .z-1 // z-index from $z-indexes config

Legacy

Renamed in v2

  1. .position-absolute // absolute position
  2. .position-absolute-c // absolute position and centered
  3. .position-absolute-v // absolute position and centered vertically
  4. .mar-h-10 // horizontal padding by size
  5. .mar-v-10 // vertical padding by size
  6. .pad-h-10 // horizontal padding by size
  7. .pad-v-10 // vertical padding by size
  8. .hover-underline // underline on hover
  9. .no-underline // remove text decoration