Navigation Menu

Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
[Chore] Update codebase to use prettier auto-styling
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Apr 1, 2019
1 parent 8eeed55 commit 7b28277
Show file tree
Hide file tree
Showing 9 changed files with 241 additions and 205 deletions.
2 changes: 2 additions & 0 deletions .prettierignore
@@ -0,0 +1,2 @@
node_modules
dist
7 changes: 7 additions & 0 deletions .prettierrc
@@ -0,0 +1,7 @@
{
"printWidth": 80,
"singleQuote": true,
"quote-props": "consistent",
"trailingComma": "es5",
"arrowParens": "always"
}
57 changes: 43 additions & 14 deletions README.md
@@ -1,4 +1,5 @@
# object-fit-polyfill

A polyfill for browsers that don't support the `object-fit` CSS property. Unsure of what the `object-fit` does? Essentially `object-fit` is to `<img>` tags what `background-size` is to `background-image`. You can check out the [MDN page](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit) for more details.

## Features
Expand Down Expand Up @@ -38,20 +39,25 @@ Initialization:
```html
<!-- Minimum CSS -->
<style>
.container {
width: 25em; /* Or whatever you want it to be */
height: 25em; /* Or whatever you want it to be */
}
.media {
width: 100%;
height: 100%;
object-fit: cover; /* Or whatever object-fit you want */
}
.container {
width: 25em; /* Or whatever you want it to be */
height: 25em; /* Or whatever you want it to be */
}
.media {
width: 100%;
height: 100%;
object-fit: cover; /* Or whatever object-fit you want */
}
</style>

<!-- Minimum HTML -->
<div class="container">
<img class="media" data-object-fit="cover" src="https://unsplash.it/800/600/" alt="">
<img
alt=""
src="https://unsplash.it/800/600/"
class="media"
data-object-fit="cover"
/>
</div>

<script src="dist/objectFitPolyfill.min.js"></script>
Expand All @@ -61,23 +67,46 @@ Customized object-fit/object-position:

```html
<div class="container">
<img class="media" data-object-fit="contain" data-object-position="top left" src="https://unsplash.it/800/600/" alt="">
<img
alt=""
src="https://unsplash.it/800/600/"
class="media"
data-object-fit="contain"
data-object-position="top left"
/>
</div>

<div class="container">
<img class="media" data-object-fit="none" data-object-position="25% 75%" src="https://unsplash.it/800/600/" alt="">
<img
alt=""
src="https://unsplash.it/800/600/"
class="media"
data-object-fit="none"
data-object-position="25% 75%"
/>
</div>

<div class="container">
<img class="media" data-object-fit="scale-down" data-object-position="3em -1em" src="https://unsplash.it/800/600/" alt="">
<img
alt=""
src="https://unsplash.it/800/600/"
class="media"
data-object-fit="scale-down"
data-object-position="3em -1em"
/>
</div>
```

If you're only interested in using the basic polyfill (which assumes `object-fit: cover` and `object-position: 50% 50%`), you can save yourself some bytes by using:

```html
<div class="container">
<img class="media" data-object-fit src="https://unsplash.it/800/600/" alt="">
<img
alt=""
src="https://unsplash.it/800/600/"
class="media"
data-object-fit
/>
</div>

<script src="dist/objectFitPolyfill.basic.min.js"></script>
Expand Down
13 changes: 8 additions & 5 deletions demo/style.css
@@ -1,15 +1,18 @@
html, body {
html,
body {
margin: 0;
height: 100%;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
Arial, sans-serif;
line-height: 1.5;
background-color: #111;
color: #fff;
}
a {
color: inherit;
}
h1, h2 {
h1,
h2 {
margin: 0;
}

Expand All @@ -20,7 +23,7 @@ h1, h2 {
.heading-intro {
position: relative;
top: 50%;
background-color: rgba(0,0,0, 0.8);
background-color: rgba(0, 0, 0, 0.8);
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
Expand All @@ -31,7 +34,7 @@ h1, h2 {
*/

.clearfix::after {
content: "";
content: '';
display: table;
clear: both;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/objectFitPolyfill.basic.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/objectFitPolyfill.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions gulpfile.js
@@ -1,15 +1,16 @@
"use strict";
'use strict';

var gulp = require("gulp"),
uglify = require("gulp-uglify"),
rename = require("gulp-rename");
var gulp = require('gulp'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename');

/*----------------------------------------------
Uglify JS
-----------------------------------------------*/
gulp.task("default", function() {
return gulp.src("src/*.js")
gulp.task('default', function() {
return gulp
.src('src/*.js')
.pipe(uglify())
.pipe(rename({suffix: ".min"}))
.pipe(gulp.dest("dist/"));
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist/'));
});

0 comments on commit 7b28277

Please sign in to comment.