Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                .app(ng-app='app', ng-controller='ctrl')
  header
    h1 News Feed
  .news-categories(ng-init='newsCategory = "business"')
    .news-category(ng-repeat='category in categories', ng-click='$parent.newsCategory = category; getSources()', class='{{category}}')
      i.ion.ion-checkmark(ng-show='$parent.newsCategory == category')
      span {{ category == "science-and-nature" ? "science" : category }}
  .news-sources
    .news-source(ng-repeat='source in sources', ng-click='$parent.newsSource = source.id; getArticles()', style='background-image: url({{ source.urlsToLogos.large }})')
      i.ion.ion-checkmark(ng-show='$parent.newsSource == source.id')


  main.news-feed
    a.news-feed__article(ng-repeat='article in articles', href='{{ article.url }}')
      h3.news-feed__article__title {{ article.title }}
      img.news-feed__article__image(src='{{ article.urlToImage }}')
      p.news-feed__article__description {{ article.description }}
      small.news-feed__article__author {{ article.author }}

              
            
!

CSS

              
                
*
  margin: 0
  padding: 0
  box-sizing: border-box
  line-height: 1.35
  font:
    weight: 300
    family: 'Roboto', sans-serif

body, p
  color: #424242
 
h1, h2, h3, h4, h5, h6
  color: #212121
  text-align: center
  
.business
  background: #f44336
.entertainment
  background: #E91E63
.gaming
  background: #9C27B0
.general
  background: #673AB7
.music
  background: #3F51B5
.science-and-nature
  background: #2196F3
.sport
  background: #00BCD4
.technology
  background: #009688
  
.ion
  position: absolute
  top: 50%
  left: 50%
  transform: translate(-50%,-50%)
  font-size: 2.5em
  text-shadow: 1px 1px rgba(0,0,0,0.66)
  color: #4CAF50
  
.news-sources
  display: flex
  flex-wrap: wrap
  justify-content: space-around
  
  .news-source
    position: relative
    display: flex
    align-items: center
    justify-content: center
    text-transform: capitalize
    border: 1px solid white
    width: calc(25% - 0.66em)
    height: 25vw
    cursor: pointer
    background:
      size: contain
      position: center
      repeat: no-repeat
    .ion
      font-size: 15vmin
      


.news-categories
  display: flex
  flex-wrap: wrap
  .news-category
    position: relative
    display: flex
    align-items: center
    justify-content: center
    text-transform: capitalize
    border: 1px solid white
    text-shadow: 1px 1px rgba(0,0,0,0.33)
    color: white
    width: 25%
    height: 3em
    cursor: pointer
    &.active
      background: green
    
.news-feed
  padding: 0.33em
  display: flex
  flex-wrap: wrap
  justify-content: center
  &__article
    display: flex
    flex-direction: column
    justify-content: space-between
    margin: 0 auto
    text-decoration: none
    border-radius: 2px
    padding: 0.66em
    margin: 0.5em
    max-width: 60ch
     
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24)
    transition: all 0.3s cubic-bezier(.25,.8,.25,1)

    &:hover 
      box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22)
    
    > * + *
      margin: 0.66em auto 0 auto
    &__title
      text-align: center
    &__image
      width: 100%
      height: auto
      display: block
    &__description
      max-width: 60ch
    &__url
      display: block
      border: none
      background: none
      border-radius: 2px
      width: 11ch
      box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24)
      transition: all 0.3s cubic-bezier(.25,.8,.25,1)

      &:hover 
        box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22)
    &__author
      color: #616161
      text-align: right
  
    


body
  /* ===== == = === Base Styles === = == ===== */
  font-size: 11px
  .news-feed__article
    width: calc(100% - 1rem)

  /* ===== == = === 20em (320px) === = == ===== */
  @media (min-width : 20rem)
    font-size: 12px
      
  /* ===== == = === 30em (480px) === = == ===== */
  @media (min-width : 30rem)
    font-size: 13px
    .news-feed__article
      width: calc(50% - 1em)
      
  /* ===== == = === 37.5em (600px) === = == ===== */
  @media (min-width: 37.5rem)
    font-size: 13.75px


  /* ===== == = === 48em (768px) === = == ===== */
  @media (min-width : 48rem)
    font-size: 14.8px
    .news-feed__article
      width: calc(25% - 1em)
  /* ===== == = === 62.25em (992px) === = == ===== */
  @media (min-width : 62em)
    font-size: 16.2px


  /* ===== == = === 68.75em (1100px) === = == ===== */
  @media (min-width : 68.75rem)
    font-size: 16.875px
    .news-feed__article
      width: calc(20% - 1em)

  /* ===== == = === 81.25em (1300px) === = == ===== */
  @media (min-width : 81.25rem)
    font-size: 18.125px
    
    
    


              
            
!

JS

              
                var app = angular.module('app', []);

app.controller('ctrl', ['$scope', '$http', function($scope, $http) {

  $scope.newsCategory   = 'business';
  $scope.newsSource     = 'bloomberg';
  
  $scope.getSources = function() {
  $http({
  method: 'GET',
  url: 'https://newsapi.org/v1/sources',
  params: {
    language: 'en',
    category: $scope.newsCategory
  }
}).then(function successCallback(response) {
    $scope.sources = response.data.sources;
  }, function errorCallback(response) { 
    console.error( response );
  });
  };
  
  
  $scope.getArticles = function() {
    $http({
      method: 'GET',
      url: 'https://newsapi.org/v1/articles',
      params: {
        source: $scope.newsSource,
        apiKey: '3bddb1bdbb1948f9b1728a78184a0979'
      }
    }).then(function successCallback(response) {    
      $scope.articles = response.data.articles;
    }, function errorCallback(response) {
      console.error( response );
    });
  };
  
  $scope.getSources();
  $scope.getArticles();
  
  $scope.categories = ['business', 'entertainment', 'gaming', 'general', 'music', 'science-and-nature', 'sport', 'technology']
  

  
  
}]);

              
            
!
999px

Console