css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              .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 }}

            
          
!
            
              
*
  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
    
    
    


            
          
!
            
              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
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console